Added in API level 1

BaseExpandableListAdapter


public abstract class BaseExpandableListAdapter
extends Object implements ExpandableListAdapter, HeterogeneousExpandableList

java.lang.Object
   ↳ android.widget.BaseExpandableListAdapter
CursorTreeAdapter An adapter that exposes data from a series of Cursors to an ExpandableListView widget. 
SimpleExpandableListAdapter An easy adapter to map static data to group and child views defined in an XML file. 
ResourceCursorTreeAdapter A fairly simple ExpandableListAdapter that creates views defined in an XML file. 
SimpleCursorTreeAdapter An easy adapter to map columns from a cursor to TextViews or ImageViews defined in an XML file. 


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.

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 ExpandableListAdapter.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 ExpandableListAdapter.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 ExpandableListAdapter.getGroupView(int, boolean, View, ViewGroup) .

    int getGroupTypeCount()

    Returns the number of types of group Views that will be created by ExpandableListAdapter.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

    Object clone()

    Creates and returns a copy of this object.

    boolean equals(Object obj)

    Indicates whether some other object is "equal to" this one.

    void finalize()

    Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

    final Class<?> getClass()

    Returns the runtime class of this Object.

    int hashCode()

    Returns a hash code value for the object.

    final void notify()

    Wakes up a single thread that is waiting on this object's monitor.

    final void notifyAll()

    Wakes up all threads that are waiting on this object's monitor.

    String toString()

    Returns a string representation of the object.

    final void wait(long timeoutMillis, int nanos)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

    final void wait(long timeoutMillis)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

    final void wait()

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

    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)
    abstract int getChildType(int groupPosition, int childPosition)

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

    abstract int getChildTypeCount()

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

    abstract int getGroupType(int groupPosition)

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

    abstract int getGroupTypeCount()

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

    Public constructors

    BaseExpandableListAdapter

    public BaseExpandableListAdapter ()

    Public methods

    areAllItemsEnabled

    Added in API level 1
    public boolean areAllItemsEnabled ()

    Returns
    boolean

    getChildType

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

    Get the type of child View that will be created by ExpandableListAdapter.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
    public int getChildTypeCount ()

    Returns the number of types of child Views that will be created by ExpandableListAdapter.getChildView(int, int, boolean, View, ViewGroup) . Each type represents a set of views that can be converted in ExpandableListAdapter.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
    public 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
    public 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
    public int getGroupType (int groupPosition)

    Get the type of group View that will be created by ExpandableListAdapter.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
    public int getGroupTypeCount ()

    Returns the number of types of group Views that will be created by ExpandableListAdapter.getGroupView(int, boolean, View, ViewGroup) . Each type represents a set of views that can be converted in ExpandableListAdapter.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
    public boolean isEmpty ()

    Returns
    boolean

    notifyDataSetChanged

    Added in API level 1
    public void notifyDataSetChanged ()

    notifyDataSetInvalidated

    Added in API level 1
    public void notifyDataSetInvalidated ()

    onGroupCollapsed

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

    Called when a group is collapsed.

    Parameters
    groupPosition int: The group being collapsed.

    onGroupExpanded

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

    Called when a group is expanded.

    Parameters
    groupPosition int: The group being expanded.

    registerDataSetObserver

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

    Parameters
    observer DataSetObserver

    unregisterDataSetObserver

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

    Parameters
    observer DataSetObserver