Added in API level 1

ExpandableListView


open class ExpandableListView : ListView
kotlin.Any
   ↳ 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.

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(android.graphics.drawable.Drawable) or setGroupIndicator(android.graphics.drawable.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 ExpandableListContextMenuInfo object with ExpandableListContextMenuInfo.packedPosition being a packed position that can be used with getPackedPositionType(long) 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.

Summary

Nested classes
open

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

abstract

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

abstract

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

abstract

Used for being notified when a group is collapsed

abstract

Used for being notified when a group is expanded

XML attributes
android:childDivider Drawable or color that is used as a divider for children.
android:childIndicator Indicator shown beside the child View.
android:childIndicatorEnd The end bound for a child's indicator.
android:childIndicatorLeft The left bound for a child's indicator.
android:childIndicatorRight The right bound for a child's indicator.
android:childIndicatorStart The start bound for a child's indicator.
android:groupIndicator Indicator shown beside the group View.
android:indicatorEnd The end bound for an item's indicator.
android:indicatorLeft The left bound for an item's indicator.
android:indicatorRight The right bound for an item's indicator.
android:indicatorStart The start bound for an item's indicator.
Inherited XML attributes
Constants
static Int

Denotes when a child indicator should inherit this bound from the generic indicator bounds

static Int

The packed position represents a child.

static Int

The packed position represents a group.

static Int

The packed position represents a neither/null/no preference.

static Long

The value for a packed position that represents neither/null/no preference.

Inherited constants
Public constructors

ExpandableListView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

ExpandableListView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Boolean
collapseGroup(groupPos: Int)

Collapse a group in the grouped list view

open Boolean
expandGroup(groupPos: Int)

Expand a group in the grouped list view

open Boolean
expandGroup(groupPos: Int, animate: Boolean)

Expand a group in the grouped list view

open CharSequence!

open ListAdapter!

This method should not be used, use getExpandableListAdapter().

open ExpandableListAdapter!

Gets the adapter that provides data to this view.

open Long
getExpandableListPosition(flatListPosition: Int)

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).

open Int
getFlatListPosition(packedPosition: Long)

Converts a group and/or child position to a flat list position.

open static Int
getPackedPositionChild(packedPosition: Long)

Gets the child position from a packed position that is of PACKED_POSITION_TYPE_CHILD type (use getPackedPositionType(long)).

open static Long
getPackedPositionForChild(groupPosition: Int, childPosition: Int)

Returns the packed position representation of a child's position.

open static Long

Returns the packed position representation of a group's position.

open static Int
getPackedPositionGroup(packedPosition: Long)

Gets the group position from a packed position.

open static Int
getPackedPositionType(packedPosition: Long)

Gets the type of a packed position.

open Long

Gets the ID of the currently selected group or child.

open Long

Gets the position of the currently selected group or child (along with its type).

open Boolean
isGroupExpanded(groupPosition: Int)

Whether the given group is currently expanded.

open Unit

open Unit
onRtlPropertiesChanged(layoutDirection: Int)

open Parcelable?

open Boolean
performItemClick(v: View!, position: Int, id: Long)

open Unit

Sets the adapter that provides data to this view.

open Unit

This overloaded method should not be used, instead use setAdapter(android.widget.ExpandableListAdapter).

open Unit
setChildDivider(childDivider: Drawable!)

Sets the drawable that will be drawn adjacent to every child in the list.

open Unit
setChildIndicator(childIndicator: Drawable!)

Sets the indicator to be drawn next to a child.

open Unit

Sets the drawing bounds for the child indicator.

open Unit

Sets the relative drawing bounds for the child indicator.

open Unit
setGroupIndicator(groupIndicator: Drawable!)

Sets the indicator to be drawn next to a group.

open Unit
setIndicatorBounds(left: Int, right: Int)

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).

open Unit

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).

open Unit

open Unit

open Unit

open Unit

open Unit

Register a callback to be invoked when an item has been clicked and the caller prefers to receive a ListView-style position instead of a group and/or child position.

open Boolean
setSelectedChild(groupPosition: Int, childPosition: Int, shouldExpandGroup: Boolean)

Sets the selection to the specified child.

open Unit
setSelectedGroup(groupPosition: Int)

Sets the selection to the specified group.

Protected methods
open Unit

Inherited functions