Most visited

Recently visited

Added in API level 1

BaseExpandableListAdapter

public abstract class BaseExpandableListAdapter
extends Object implements ExpandableListAdapter, HeterogeneousExpandableList

java.lang.Object
   ↳ android.widget.BaseExpandableListAdapter
Known Direct Subclasses
Known Indirect Subclasses


Base class for a ExpandableListAdapter used to provide data and Views from some data to an expandable list view.

Adapters inheriting this class should verify that the base implementations of getCombinedChildId(long, long) and getCombinedGroupId(long) are correct in generating unique IDs from the group/children IDs.

See also:

Summary

Public constructors

BaseExpandableListAdapter()

Public methods

boolean areAllItemsEnabled()
int getChildType(int groupPosition, int childPosition)

Get the type of child View that will be created by getChildView(int, int, boolean, View, ViewGroup) for the specified child item.

int getChildTypeCount()

Returns the number of types of child Views that will be created by getChildView(int, int, boolean, View, ViewGroup) .

long getCombinedChildId(long groupId, long childId)

Override this method if you foresee a clash in IDs based on this scheme:

Base implementation returns a long:

  • bit 0: Whether this ID points to a child (unset) or group (set), so for this method this bit will be 1.

  • long getCombinedGroupId(long groupId)

    Override this method if you foresee a clash in IDs based on this scheme:

    Base implementation returns a long:

  • bit 0: Whether this ID points to a child (unset) or group (set), so for this method this bit will be 0.

  • int getGroupType(int groupPosition)

    Get the type of group View that will be created by getGroupView(int, boolean, View, ViewGroup) .

    int getGroupTypeCount()

    Returns the number of types of group Views that will be created by getGroupView(int, boolean, View, ViewGroup) .

    boolean isEmpty()

    void notifyDataSetChanged()
    void notifyDataSetInvalidated()
    void onGroupCollapsed(int groupPosition)

    Called when a group is collapsed.

    void onGroupExpanded(int groupPosition)

    Called when a group is expanded.

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

    Inherited methods

    From class java.lang.Object
    From interface android.widget.ExpandableListAdapter
    From interface android.widget.HeterogeneousExpandableList

    Public constructors

    BaseExpandableListAdapter

    Added in API level 1
    BaseExpandableListAdapter ()

    Public methods

    areAllItemsEnabled

    Added in API level 1
    boolean areAllItemsEnabled ()

    Returns
    boolean

    getChildType

    Added in API level 8
    int getChildType (int groupPosition, 
                    int childPosition)

    Get the type of child View that will be created by getChildView(int, int, boolean, View, ViewGroup) for the specified child item.

    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
    int 0 for any group or child position, since only one child type count is declared.

    getChildTypeCount

    Added in API level 8
    int getChildTypeCount ()

    Returns the number of types of child Views that will be created by getChildView(int, int, boolean, View, ViewGroup) . Each type represents a set of views that can be converted in getChildView(int, int, boolean, View, ViewGroup) , for any group. If the adapter always returns the same type of View for all child items, this method should return 1.

    This method will only be called when the adapter is set on the AdapterView.

    Returns
    int 1 as a default value in BaseExpandableListAdapter.

    getCombinedChildId

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

    Override this method if you foresee a clash in IDs based on this scheme:

    Base implementation returns a long:

  • bit 0: Whether this ID points to a child (unset) or group (set), so for this method this bit will be 1.
  • bit 1-31: Lower 31 bits of the groupId
  • bit 32-63: Lower 32 bits of the 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
    long getCombinedGroupId (long groupId)

    Override this method if you foresee a clash in IDs based on this scheme:

    Base implementation returns a long:

  • bit 0: Whether this ID points to a child (unset) or group (set), so for this method this bit will be 0.
  • bit 1-31: Lower 31 bits of the groupId
  • bit 32-63: Lower 32 bits of the childId.

    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.
  • getGroupType

    Added in API level 8
    int getGroupType (int groupPosition)

    Get the type of group View that will be created by getGroupView(int, boolean, View, ViewGroup) . for the specified group item.

    Parameters
    groupPosition int: the position of the group for which the type should be returned.
    Returns
    int 0 for any groupPosition, since only one group type count is declared.

    getGroupTypeCount

    Added in API level 8
    int getGroupTypeCount ()

    Returns the number of types of group Views that will be created by getGroupView(int, boolean, View, ViewGroup) . Each type represents a set of views that can be converted in getGroupView(int, boolean, View, ViewGroup) . If the adapter always returns the same type of View for all group items, this method should return 1.

    This method will only be called when the adapter is set on the AdapterView.

    Returns
    int 1 as a default value in BaseExpandableListAdapter.

    isEmpty

    Added in API level 1
    boolean isEmpty ()

    Returns
    boolean

    notifyDataSetChanged

    Added in API level 1
    void notifyDataSetChanged ()

    See also:

    notifyDataSetInvalidated

    Added in API level 1
    void notifyDataSetInvalidated ()

    See also:

    onGroupCollapsed

    Added in API level 1
    void onGroupCollapsed (int groupPosition)

    Called when a group is collapsed.

    Parameters
    groupPosition int: The group being collapsed.

    onGroupExpanded

    Added in API level 1
    void onGroupExpanded (int groupPosition)

    Called when a group is expanded.

    Parameters
    groupPosition int: The group being expanded.

    registerDataSetObserver

    Added in API level 1
    void registerDataSetObserver (DataSetObserver observer)

    Parameters
    observer DataSetObserver

    unregisterDataSetObserver

    Added in API level 1
    void unregisterDataSetObserver (DataSetObserver observer)

    Parameters
    observer DataSetObserver

    Hooray!