public abstract class GroupingListAdapter extends BaseAdapter
Modifier and Type | Class and Description |
---|---|
protected static class |
GroupingListAdapter.PositionMetadata
Information about a specific list item: is it a group, if so is it expanded.
|
Modifier and Type | Field and Description |
---|---|
static int |
ITEM_TYPE_GROUP_HEADER |
static int |
ITEM_TYPE_IN_GROUP |
static int |
ITEM_TYPE_STANDALONE |
protected ContentObserver |
mChangeObserver |
protected DataSetObserver |
mDataSetObserver |
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
Constructor and Description |
---|
GroupingListAdapter(Context context) |
Modifier and Type | Method and Description |
---|---|
protected void |
addGroup(int cursorPosition,
int size,
boolean expanded)
Records information about grouping in the list.
|
protected abstract void |
addGroups(Cursor cursor)
Finds all groups of adjacent items in the cursor and calls
addGroup(int, int, boolean) for
each of them. |
protected abstract void |
bindChildView(View view,
Context context,
Cursor cursor) |
protected abstract void |
bindGroupView(View view,
Context context,
Cursor cursor,
int groupSize,
boolean expanded) |
protected abstract void |
bindStandAloneView(View view,
Context context,
Cursor cursor) |
void |
changeCursor(Cursor cursor) |
int |
getCount()
How many items are in the data set represented by this Adapter.
|
Cursor |
getCursor() |
int |
getGroupSize(int position)
Given a position of a groups header in the list, returns the size of
the corresponding group.
|
Object |
getItem(int position)
Get the data item associated with the specified position in the data set.
|
long |
getItemId(int position)
Get the row id associated with the specified position in the list.
|
int |
getItemViewType(int position)
Get the type of View that will be created by
Adapter.getView(int, android.view.View, android.view.ViewGroup) for the specified item. |
View |
getView(int position,
View convertView,
ViewGroup parent)
Get a View that displays the data at the specified position in the data set.
|
int |
getViewTypeCount()
Returns the number of types of Views that will be created by
Adapter.getView(int, android.view.View, android.view.ViewGroup) . |
boolean |
isGroupHeader(int position)
Returns true if the specified position in the list corresponds to a
group header.
|
protected abstract View |
newChildView(Context context,
ViewGroup parent) |
protected abstract View |
newGroupView(Context context,
ViewGroup parent) |
protected abstract View |
newStandAloneView(Context context,
ViewGroup parent) |
void |
obtainPositionMetadata(GroupingListAdapter.PositionMetadata metadata,
int position)
Figures out whether the item at the specified position represents a
stand-alone element, a group or a group child.
|
protected void |
onContentChanged() |
void |
toggleGroup(int position)
Mark group as expanded if it is collapsed and vice versa.
|
areAllItemsEnabled, getDropDownView, hasStableIds, isEmpty, isEnabled, notifyDataSetChanged, notifyDataSetInvalidated, registerDataSetObserver, unregisterDataSetObserver
public static final int ITEM_TYPE_STANDALONE
public static final int ITEM_TYPE_GROUP_HEADER
public static final int ITEM_TYPE_IN_GROUP
protected ContentObserver mChangeObserver
protected DataSetObserver mDataSetObserver
public GroupingListAdapter(Context context)
protected abstract void addGroups(Cursor cursor)
addGroup(int, int, boolean)
for
each of them.protected abstract void bindStandAloneView(View view, Context context, Cursor cursor)
protected abstract void bindGroupView(View view, Context context, Cursor cursor, int groupSize, boolean expanded)
protected void onContentChanged()
public void changeCursor(Cursor cursor)
public Cursor getCursor()
protected void addGroup(int cursorPosition, int size, boolean expanded)
addGroups(android.database.Cursor)
method.public int getCount()
Adapter
public void obtainPositionMetadata(GroupingListAdapter.PositionMetadata metadata, int position)
public boolean isGroupHeader(int position)
public int getGroupSize(int position)
public void toggleGroup(int position)
public int getViewTypeCount()
Adapter
Returns the number of types of Views that will be created by
Adapter.getView(int, android.view.View, android.view.ViewGroup)
. Each type represents a set of views that can be
converted in Adapter.getView(int, android.view.View, android.view.ViewGroup)
. If the adapter always returns the same
type of View for all items, this method should return 1.
This method will only be called when the adapter is set on the AdapterView
.
getViewTypeCount
in interface Adapter
getViewTypeCount
in class BaseAdapter
public int getItemViewType(int position)
Adapter
Adapter.getView(int, android.view.View, android.view.ViewGroup)
for the specified item.getItemViewType
in interface Adapter
getItemViewType
in class BaseAdapter
position
- The position of the item within the adapter's data set whose view type we
want.Adapter.getView(int, android.view.View, android.view.ViewGroup)
. Note: Integers must be in the
range 0 to Adapter.getViewTypeCount()
- 1. Adapter.IGNORE_ITEM_VIEW_TYPE
can
also be returned.Adapter.IGNORE_ITEM_VIEW_TYPE
public Object getItem(int position)
Adapter
position
- Position of the item whose data we want within the adapter's
data set.public long getItemId(int position)
Adapter
position
- The position of the item within the adapter's data set whose row id we want.public View getView(int position, View convertView, ViewGroup parent)
Adapter
LayoutInflater.inflate(int, android.view.ViewGroup, boolean)
to specify a root view and to prevent attachment to the root.position
- The position of the item within the adapter's data set of the item whose view
we want.convertView
- The old view to reuse, if possible. Note: 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.
Heterogeneous lists can specify their number of view types, so that this View is
always of the right type (see Adapter.getViewTypeCount()
and
Adapter.getItemViewType(int)
).parent
- The parent that this view will eventually be attached to