public abstract class BaseExpandableListAdapter extends Object implements ExpandableListAdapter, HeterogeneousExpandableList
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.
Constructor and Description |
---|
BaseExpandableListAdapter() |
Modifier and Type | Method and Description |
---|---|
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)
. for the specified group item. |
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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getChild, getChildId, getChildrenCount, getChildView, getGroup, getGroupCount, getGroupId, getGroupView, hasStableIds, isChildSelectable
public void registerDataSetObserver(DataSetObserver observer)
registerDataSetObserver
in interface ExpandableListAdapter
Adapter.registerDataSetObserver(DataSetObserver)
public void unregisterDataSetObserver(DataSetObserver observer)
unregisterDataSetObserver
in interface ExpandableListAdapter
Adapter.unregisterDataSetObserver(DataSetObserver)
public void notifyDataSetInvalidated()
DataSetObservable.notifyInvalidated()
public void notifyDataSetChanged()
DataSetObservable.notifyChanged()
public boolean areAllItemsEnabled()
areAllItemsEnabled
in interface ExpandableListAdapter
ListAdapter.areAllItemsEnabled()
public void onGroupCollapsed(int groupPosition)
ExpandableListAdapter
onGroupCollapsed
in interface ExpandableListAdapter
groupPosition
- The group being collapsed.public void onGroupExpanded(int groupPosition)
ExpandableListAdapter
onGroupExpanded
in interface ExpandableListAdapter
groupPosition
- The group being expanded.public long getCombinedChildId(long groupId, long childId)
Base implementation returns a long:
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 ExpandableListAdapter.hasStableIds()
is true, the
returned ID must be stable as well.
getCombinedChildId
in interface ExpandableListAdapter
groupId
- The ID of the group that contains this child.childId
- The ID of the child.public long getCombinedGroupId(long groupId)
Base implementation returns a long:
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 ExpandableListAdapter.hasStableIds()
is true, the returned ID must be
stable as well.
getCombinedGroupId
in interface ExpandableListAdapter
groupId
- The ID of the grouppublic boolean isEmpty()
isEmpty
in interface ExpandableListAdapter
Adapter.isEmpty()
public int getChildType(int groupPosition, int childPosition)
ExpandableListAdapter.getChildView(int, int, boolean, View, ViewGroup)
for the specified child item.getChildType
in interface HeterogeneousExpandableList
groupPosition
- the position of the group that the child resides inchildPosition
- the position of the child with respect to other children in the groupAdapter.IGNORE_ITEM_VIEW_TYPE
,
HeterogeneousExpandableList.getChildTypeCount()
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.
AdapterView
.getChildTypeCount
in interface HeterogeneousExpandableList
HeterogeneousExpandableList.getGroupTypeCount()
,
HeterogeneousExpandableList.getChildType(int, int)
public int getGroupType(int groupPosition)
ExpandableListAdapter.getGroupView(int, boolean, View, ViewGroup)
. for the specified group item.getGroupType
in interface HeterogeneousExpandableList
groupPosition
- the position of the group for which the type should be returned.Adapter.IGNORE_ITEM_VIEW_TYPE
,
HeterogeneousExpandableList.getGroupTypeCount()
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.
AdapterView
.getGroupTypeCount
in interface HeterogeneousExpandableList
HeterogeneousExpandableList.getChildTypeCount()
,
HeterogeneousExpandableList.getGroupType(int)