public abstract class CompositeCursorAdapter extends BaseAdapter
Modifier and Type | Class and Description |
---|---|
static class |
CompositeCursorAdapter.Partition |
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
Constructor and Description |
---|
CompositeCursorAdapter(Context context) |
CompositeCursorAdapter(Context context,
int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
void |
addPartition(boolean showIfEmpty,
boolean hasHeader)
Registers a partition.
|
void |
addPartition(CompositeCursorAdapter.Partition partition) |
void |
addPartition(int location,
CompositeCursorAdapter.Partition partition) |
boolean |
areAllItemsEnabled()
Returns false if any partition has a header.
|
protected void |
bindHeaderView(View view,
int partition,
Cursor cursor)
Binds the header view for the specified partition.
|
protected abstract void |
bindView(View v,
int partition,
Cursor cursor,
int position)
Binds an item view for the specified partition and position.
|
void |
changeCursor(int partition,
Cursor cursor)
Changes the cursor for an individual partition.
|
void |
clearPartitions()
Removes cursors for all partitions.
|
void |
close()
Closes all cursors and removes all partitions.
|
protected void |
ensureCacheValid() |
Context |
getContext() |
int |
getCount()
Returns the total number of list items in all partitions.
|
Cursor |
getCursor(int partition)
Returns the cursor for the given partition
|
protected View |
getHeaderView(int partition,
Cursor cursor,
View convertView,
ViewGroup parent)
Returns the header view for the specified partition, creating one if needed.
|
Object |
getItem(int position)
Returns a pre-positioned cursor for the specified list position.
|
long |
getItemId(int position)
Returns the item ID for the specified list position.
|
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. |
protected int |
getItemViewType(int partition,
int position)
Returns the view type for the list item at the specified position in the
specified partition.
|
int |
getItemViewTypeCount()
Returns the overall number of item view types across all partitions.
|
int |
getOffsetInPartition(int position)
Given a list position, return the offset of the corresponding item in its
partition.
|
CompositeCursorAdapter.Partition |
getPartition(int partitionIndex) |
int |
getPartitionCount() |
int |
getPartitionForPosition(int position)
Given a list position, returns the index of the corresponding partition.
|
int |
getPositionForPartition(int partition)
Returns the first list position for the specified partition.
|
protected View |
getView(int partition,
Cursor cursor,
int position,
View convertView,
ViewGroup parent)
Returns an item view for the specified partition, creating one if needed.
|
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 |
hasHeader(int partition)
Returns true if the specified partition was configured to have a header.
|
protected void |
invalidate() |
boolean |
isEnabled(int position)
Returns true for all items except headers.
|
protected boolean |
isEnabled(int partition,
int position)
Returns true if the item at the specified offset of the specified
partition is selectable and clickable.
|
boolean |
isPartitionEmpty(int partition)
Returns true if the specified partition has no cursor or an empty cursor.
|
protected View |
newHeaderView(Context context,
int partition,
Cursor cursor,
ViewGroup parent)
Creates the header view for the specified partition.
|
protected abstract View |
newView(Context context,
int partition,
Cursor cursor,
int position,
ViewGroup parent)
Creates an item view for the specified partition and position.
|
void |
notifyDataSetChanged()
Notifies the attached observers that the underlying data has been changed
and any View reflecting the data set should refresh itself.
|
void |
removePartition(int partitionIndex) |
void |
setHasHeader(int partitionIndex,
boolean flag) |
void |
setNotificationsEnabled(boolean flag)
Enable or disable data change notifications.
|
void |
setShowIfEmpty(int partitionIndex,
boolean flag) |
getDropDownView, hasStableIds, isEmpty, notifyDataSetInvalidated, registerDataSetObserver, unregisterDataSetObserver
public CompositeCursorAdapter(Context context)
public CompositeCursorAdapter(Context context, int initialCapacity)
public Context getContext()
public void addPartition(boolean showIfEmpty, boolean hasHeader)
public void addPartition(CompositeCursorAdapter.Partition partition)
public void addPartition(int location, CompositeCursorAdapter.Partition partition)
public void removePartition(int partitionIndex)
public void clearPartitions()
public void close()
public void setHasHeader(int partitionIndex, boolean flag)
public void setShowIfEmpty(int partitionIndex, boolean flag)
public CompositeCursorAdapter.Partition getPartition(int partitionIndex)
protected void invalidate()
public int getPartitionCount()
protected void ensureCacheValid()
public boolean hasHeader(int partition)
public int getCount()
public Cursor getCursor(int partition)
public void changeCursor(int partition, Cursor cursor)
public boolean isPartitionEmpty(int partition)
public int getPartitionForPosition(int position)
public int getOffsetInPartition(int position)
public int getPositionForPartition(int partition)
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 getItemViewTypeCount()
getItemViewType(int,int)
.protected int getItemViewType(int partition, int position)
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 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 toprotected View getHeaderView(int partition, Cursor cursor, View convertView, ViewGroup parent)
protected View newHeaderView(Context context, int partition, Cursor cursor, ViewGroup parent)
protected void bindHeaderView(View view, int partition, Cursor cursor)
protected View getView(int partition, Cursor cursor, int position, View convertView, ViewGroup parent)
protected abstract View newView(Context context, int partition, Cursor cursor, int position, ViewGroup parent)
protected abstract void bindView(View v, int partition, Cursor cursor, int position)
public Object getItem(int position)
position
- Position of the item whose data we want within the adapter's
data set.public long getItemId(int position)
position
- The position of the item within the adapter's data set whose row id we want.public boolean areAllItemsEnabled()
areAllItemsEnabled
in interface ListAdapter
areAllItemsEnabled
in class BaseAdapter
ListAdapter.isEnabled(int)
public boolean isEnabled(int position)
isEnabled
in interface ListAdapter
isEnabled
in class BaseAdapter
position
- Index of the itemListAdapter.areAllItemsEnabled()
protected boolean isEnabled(int partition, int position)
public void setNotificationsEnabled(boolean flag)
public void notifyDataSetChanged()
BaseAdapter
notifyDataSetChanged
in class BaseAdapter