Added in API level 1

ExpandableListAdapter

public interface ExpandableListAdapter

android.widget.ExpandableListAdapter


An adapter that links a ExpandableListView with the underlying data. The implementation of this interface will provide access to the data of the children (categorized by groups), and also instantiate Views for children and groups.

Summary

Public methods

abstract boolean areAllItemsEnabled()
abstract Object getChild(int groupPosition, int childPosition)

Gets the data associated with the given child within the given group.

abstract long getChildId(int groupPosition, int childPosition)

Gets the ID for the given child within the given group.

abstract View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent)

Gets a View that displays the data for the given child within the given group.

abstract int getChildrenCount(int groupPosition)

Gets the number of children in a specified group.

abstract long getCombinedChildId(long groupId, long childId)

Gets an ID for a child that is unique across any item (either group or child) that is in this list.

abstract long getCombinedGroupId(long groupId)

Gets an ID for a group that is unique across any item (either group or child) that is in this list.

abstract Object getGroup(int groupPosition)

Gets the data associated with the given group.

abstract int getGroupCount()

Gets the number of groups.

abstract long getGroupId(int groupPosition)

Gets the ID for the group at the given position.

abstract View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)

Gets a View that displays the given group.

abstract boolean hasStableIds()

Indicates whether the child and group IDs are stable across changes to the underlying data.

abstract boolean isChildSelectable(int groupPosition, int childPosition)

Whether the child at the specified position is selectable.

abstract boolean isEmpty()
abstract void onGroupCollapsed(int groupPosition)

Called when a group is collapsed.

abstract void onGroupExpanded(int groupPosition)

Called when a group is expanded.

abstract void registerDataSetObserver(DataSetObserver observer)
abstract void unregisterDataSetObserver(DataSetObserver observer)

Public methods

areAllItemsEnabled

Added in API level 1
public abstract boolean areAllItemsEnabled ()

Returns
boolean

getChild

Added in API level 1
public abstract Object getChild (int groupPosition, 
                int childPosition)

Gets the data associated with the given child within the given group.

Parameters
groupPosition int: the position of the group that the child resides in

childPosition int: the position of the child with respect to other children in the group

Returns
Object the data of the child

getChildId

Added in API level 1
public abstract long getChildId (int groupPosition, 
                int childPosition)

Gets the ID for the given child within the given group. This ID must be unique across all children within the group. The combined ID (see getCombinedChildId(long, long)) must be unique across ALL items (groups and all children).

Parameters
groupPosition int: the position of the group that contains the child

childPosition int: the position of the child within the group for which the ID is wanted

Returns
long the ID associated with the child

getChildView

Added in API level 1
public abstract View getChildView (int groupPosition, 
                int childPosition, 
                boolean isLastChild, 
                View convertView, 
                ViewGroup parent)

Gets a View that displays the data for the given child within the given group.

Parameters
groupPosition int: the position of the group that contains the child

childPosition int: the position of the child (for which the View is returned) within the group

isLastChild boolean: Whether the child is the last child within the group

convertView View: the old view to reuse, if possible. You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view. It is not guaranteed that the convertView will have been previously created by getChildView(int, int, boolean, android.view.View, android.view.ViewGroup).

parent ViewGroup: the parent that this view will eventually be attached to

Returns
View the View corresponding to the child at the specified position

getChildrenCount

Added in API level 1
public abstract int getChildrenCount (int groupPosition)

Gets the number of children in a specified group.

Parameters
groupPosition int: the position of the group for which the children count should be returned

Returns
int the children count in the specified group

getCombinedChildId

Added in API level 1
public abstract long getCombinedChildId (long groupId, 
                long childId)

Gets an ID for a child that is unique across any item (either group or child) that is in this list. Expandable lists require each item (group or child) to have a unique ID among all children and groups in the list. This method is responsible for returning that unique ID given a child's ID and its group's ID. Furthermore, if hasStableIds() is true, the returned ID must be stable as well.

Parameters
groupId long: The ID of the group that contains this child.

childId long: The ID of the child.

Returns
long The unique (and possibly stable) ID of the child across all groups and children in this list.

getCombinedGroupId

Added in API level 1
public abstract long getCombinedGroupId (long groupId)

Gets an ID for a group that is unique across any item (either group or child) that is in this list. Expandable lists require each item (group or child) to have a unique ID among all children and groups in the list. This method is responsible for returning that unique ID given a group's ID. Furthermore, if hasStableIds() is true, the returned ID must be stable as well.

Parameters
groupId long: The ID of the group

Returns
long The unique (and possibly stable) ID of the group across all groups and children in this list.

getGroup

Added in API level 1
public abstract Object getGroup (int groupPosition)

Gets the data associated with the given group.

Parameters
groupPosition int: the position of the group

Returns
Object the data child for the specified group

getGroupCount

Added in API level 1
public abstract int getGroupCount ()

Gets the number of groups.

Returns
int the number of groups

getGroupId

Added in API level 1
public abstract long getGroupId (int groupPosition)

Gets the ID for the group at the given position. This group ID must be unique across groups. The combined ID (see getCombinedGroupId(long)) must be unique across ALL items (groups and all children).

Parameters
groupPosition int: the position of the group for which the ID is wanted

Returns
long the ID associated with the group

getGroupView

Added in API level 1
public abstract View getGroupView (int groupPosition, 
                boolean isExpanded, 
                View convertView, 
                ViewGroup parent)

Gets a View that displays the given group. This View is only for the group--the Views for the group's children will be fetched using getChildView(int, int, boolean, android.view.View, android.view.ViewGroup).

Parameters
groupPosition int: the position of the group for which the View is returned

isExpanded boolean: whether the group is expanded or collapsed

convertView View: the old view to reuse, if possible. You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view. It is not guaranteed that the convertView will have been previously created by getGroupView(int, boolean, android.view.View, android.view.ViewGroup).

parent ViewGroup: the parent that this view will eventually be attached to

Returns
View the View corresponding to the group at the specified position

hasStableIds

Added in API level 1
public abstract boolean hasStableIds ()

Indicates whether the child and group IDs are stable across changes to the underlying data.

Returns
boolean whether or not the same ID always refers to the same object

isChildSelectable

Added in API level 1
public abstract boolean isChildSelectable (int groupPosition, 
                int childPosition)

Whether the child at the specified position is selectable.

Parameters
groupPosition int: the position of the group that contains the child

childPosition int: the position of the child within the group

Returns
boolean whether the child is selectable.

isEmpty

Added in API level 1
public abstract boolean isEmpty ()

Returns
boolean

See also:

onGroupCollapsed

Added in API level 1
public abstract void onGroupCollapsed (int groupPosition)

Called when a group is collapsed.

Parameters
groupPosition int: The group being collapsed.

onGroupExpanded

Added in API level 1
public abstract void onGroupExpanded (int groupPosition)

Called when a group is expanded.

Parameters
groupPosition int: The group being expanded.

registerDataSetObserver

Added in API level 1
public abstract void registerDataSetObserver (DataSetObserver observer)

Parameters
observer DataSetObserver

unregisterDataSetObserver

Added in API level 1
public abstract void unregisterDataSetObserver (DataSetObserver observer)

Parameters
observer DataSetObserver