完整内容,请查看: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 |
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 |