Android Guides | Samples

Android.Widget.ExpandableListView Class

A view that shows items in a vertically scrolling two-level list.

See Also: ExpandableListView

Syntax

[Android.Runtime.Register("android/widget/ExpandableListView", DoNotGenerateAcw=true)]
public class ExpandableListView : ListView

Remarks

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 IExpandableListAdapter associated with this view.

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 ExpandableListView.SetChildIndicator(Drawable) or ExpandableListView.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.

The context menu information set by an ExpandableListView will be a NoType:android/widget/ExpandableListView$ExpandableListContextMenuInfo;Href=../../../reference/android/widget/ExpandableListView.ExpandableListContextMenuInfo.html object with NoType:android/widget/ExpandableListView$ExpandableListContextMenuInfo;Href=../../../reference/android/widget/ExpandableListView.ExpandableListContextMenuInfo.html#packedPosition being a packed position that can be used with ExpandableListView.GetPackedPositionType(Int64) and the other similar methods.

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.

[Android Documentation]

Requirements

Namespace: Android.Widget
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Widget.ExpandableListView are listed below.

See Also: ListView

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Fields

const
ChildIndicatorInheritInt32 (-1). Denotes when a child indicator should inherit this bound from the generic indicator bounds
const
PackedPositionValueNullInt64 (4294967295). The value for a packed position that represents neither/null/no preference.

Public Properties

[read-only]
ExpandableListAdapterIExpandableListAdapter. Gets the adapter that provides data to this view.
[read-only]
SelectedIdInt64. Gets the ID of the currently selected group or child.
[read-only]
SelectedPositionInt64. Gets the position of the currently selected group or child (along with its type).

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

CollapseGroup(Int32) : Boolean
Collapse a group in the grouped list view
ExpandGroup(Int32) : Boolean
Expand a group in the grouped list view
ExpandGroup(Int32, Boolean) : Boolean
Expand a group in the grouped list view
GetExpandableListPosition(Int32) : Int64
Converts a flat list position (the raw position of an item (child or group) in the list) to a group and/or child position (represented in a packed position).
GetFlatListPosition(Int64) : Int32
Converts a group and/or child position to a flat list position.
static
GetPackedPositionChild(Int64) : Int32
Gets the child position from a packed position that is of ExpandableListView.PACKED_POSITION_TYPE_CHILD type (use ExpandableListView.GetPackedPositionType(Int64)).
static
GetPackedPositionForChild(Int32, Int32) : Int64
Returns the packed position representation of a child's position.
static
GetPackedPositionForGroup(Int32) : Int64
Returns the packed position representation of a group's position.
static
GetPackedPositionGroup(Int64) : Int32
Gets the group position from a packed position.
static
GetPackedPositionType(Int64) : PackedPositionType
Gets the type of a packed position.
IsGroupExpanded(Int32) : Boolean
Whether the given group is currently expanded.
SetAdapter(IExpandableListAdapter)
Sets the adapter that provides data to this view.
SetChildDivider(Drawable)
Sets the drawable that will be drawn adjacent to every child in the list.
SetChildIndicator(Drawable)
Sets the indicator to be drawn next to a child.
SetChildIndicatorBounds(Int32, Int32)
Sets the drawing bounds for the child indicator.
SetChildIndicatorBoundsRelative(Int32, Int32)
Sets the relative drawing bounds for the child indicator.
SetGroupIndicator(Drawable)
Sets the indicator to be drawn next to a group.
SetIndicatorBounds(Int32, Int32)
Sets the drawing bounds for the indicators (at minimum, the group indicator is affected by this; the child indicator is affected by this if the child indicator bounds are set to inherit).
SetIndicatorBoundsRelative(Int32, Int32)
Sets the relative drawing bounds for the indicators (at minimum, the group indicator is affected by this; the child indicator is affected by this if the child indicator bounds are set to inherit).
SetOnChildClickListener(ExpandableListView+IOnChildClickListener)
SetOnGroupClickListener(ExpandableListView+IOnGroupClickListener)
SetOnGroupCollapseListener(ExpandableListView+IOnGroupCollapseListener)
SetOnGroupExpandListener(ExpandableListView+IOnGroupExpandListener)
SetSelectedChild(Int32, Int32, Boolean) : Boolean
Sets the selection to the specified child.
SetSelectedGroup(Int32)
Sets the selection to the specified group.

Public Events