您的位置:首页 > 移动开发 > Android开发

Android7.0中文文档(API)--- ExpandableListView

2017-06-14 12:09 531 查看

完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/ExpandableListView.html

ExpandableListView

public class ExpandableListView

extends

ListView


java.lang.Object
   ↳android.view.View
    ↳android.view.ViewGroup
     ↳android.widget.AdapterView<android.widget.ListAdapter>
      ↳android.widget.AbsListView
       ↳android.widget.ListView
        ↳android.widget.ExpandableListView
A view that shows items in a vertically scrolling two-level list. This differs from the
ListView
by allowing two levels: groups which can individually be expanded to show its children. The items come from the
ExpandableListAdapter
associated with this view.

一个视图,其在垂直滚动2个层次的列表中显示项。这个类与
ListView
不同,它允许显示2个层级:组项可以被单独地展开,以显示子项。这些项来自与此视图关联的
ExpandableListAdapter


Expandable lists are able to show an indicator beside each item to display the item's current state (the states are usually one of expanded group, collapsed group, child, or last child). Use
setChildIndicator(Drawable)
or
setGroupIndicator(Drawable)
(or the corresponding XML attributes) to set these
indicators (see the docs for each method to see additional state that each Drawable can have). The default style for an
ExpandableListView
provides indicators which will be shown next to Views given to the
ExpandableListView
. The layouts android.R.layout.simple_expandable_list_item_1 and android.R.layout.simple_expandable_list_item_2 (which
should be used with
SimpleCursorTreeAdapter
) contain the preferred position information for indicators.

可扩展的列表可以在每个项目旁边显示一个指示器来显示项目的当前状态(状态通常是这些之一:已展开的组项,已折叠的组项,子项,或最后一个子项)。使用
setChildIndicator(Drawable)
setChildIndicator(Drawable)
(或者对应的XML属性),来设置在这些指示器(请参考每个方法的文档,以查看每个drawable拥有的额外状态)。
ExpandableListView
的默认样式提供了一些指示器,这些指示器显示在
ExpandableListView
视图的旁边。android.R.layout.simple_expandable_list_item_1或android.R.layout.simple_expandable_list_item_2(使用
SimpleCursorTreeAdapter
)布局包含用于指示器的首选位置信息。

The context menu information set by an
ExpandableListView
will be a
ExpandableListView.ExpandableListContextMenuInfo
object with
packedPosition
being a packed position that can be used with
getPackedPositionType(long)
and the other similar methods.

ExpandableListView
是设置的上下文菜单的信息是一个
ExpandableListView.ExpandableListContextMenuInfo
对象,其包含
packedPosition
字段作为一个包装位置,可以给
getPackedPositionType(long)
和其他类似的方法使用。

Note: You cannot use the value
wrap_content
for the
android:layout_height
attribute of a ExpandableListView in XML if the parent's size is also not strictly specified (for example, if the parent were ScrollView you could not specify wrap_content since it also can be any length. However, you can
use wrap_content if the ExpandableListView parent has a specific size, such as 100 pixels.
注意:如果父项的大小也没有被严格地指定,则你不能在XML中给ExpandableListView的
android:layout_height
属性赋予
wrap_content
的值。(例如,父项是ScrollView,则你不能指定wrap_content,因为它也可以是任意长度。)但是,如果ExpandableListView的父项是指定了大小,如100像素,则你可以使用wrap_content。

摘要

嵌套类

class
ExpandableListView.ExpandableListContextMenuInfo

Extra menu information specific to an
ExpandableListView
provided to the
onCreateContextMenu(ContextMenu,
View, ContextMenuInfo)
callback when a context menu is brought up for this AdapterView. 

当为这个AdapterView弹出一个上下文菜单时,提供给
onCreateContextMenu(ContextMenu,
View, ContextMenuInfo)
方法的额外的菜单信息。 

interface
ExpandableListView.OnChildClickListener

Interface definition for a callback to be invoked when a child in this expandable list has been clicked. 

回调的接口定义,当此可扩展列表内的一个子项被点击时调用。 

interface
ExpandableListView.OnGroupClickListener

Interface definition for a callback to be invoked when a group in this expandable list has been clicked. 

回调的接口定义,当此可扩展列表内的一个组项被点击时调用。 

interface
ExpandableListView.OnGroupCollapseListener

Used for being notified when a group is collapsed  

用于当组项折叠时的通知。  

interface
ExpandableListView.OnGroupExpandListener

Used for being notified when a group is expanded  

用于当组项展开时的通知。  

XML属性

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息