ResourceCursorAdapter


public abstract class ResourceCursorAdapter
extends CursorAdapter

java.lang.Object
   ↳ android.widget.BaseAdapter
     ↳ android.widget.CursorAdapter
       ↳ android.widget.ResourceCursorAdapter
SimpleCursorAdapter An easy adapter to map columns from a cursor to TextViews or ImageViews defined in an XML file. 


An easy adapter that creates views defined in an XML file. You can specify the XML file that defines the appearance of the views.

Summary

Inherited constants

int FLAG_AUTO_REQUERY

This constant was deprecated in API level 15. This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors. As an alternative, use LoaderManager with a CursorLoader.

int FLAG_REGISTER_CONTENT_OBSERVER

If set the adapter will register a content observer on the cursor and will call onContentChanged() when a notification comes in.

int IGNORE_ITEM_VIEW_TYPE

An item view type that causes the AdapterView to ignore the item view.

int NO_SELECTION

Public constructors

ResourceCursorAdapter(Context context, int layout, Cursor c)

This constructor is deprecated. This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors. As an alternative, use LoaderManager with a CursorLoader.

ResourceCursorAdapter(Context context, int layout, Cursor c, boolean autoRequery)

Constructor with default behavior as per CursorAdapter.CursorAdapter(Context, Cursor, boolean); it is recommended you not use this, but instead ResourceCursorAdapter(android.content.Context, int, android.database.Cursor, int).

ResourceCursorAdapter(Context context, int layout, Cursor c, int flags)

Standard constructor.

Public methods

View newDropDownView(Context context, Cursor cursor, ViewGroup parent)

Makes a new drop down view to hold the data pointed to by cursor.

View newView(Context context, Cursor cursor, ViewGroup parent)

Inflates view(s) from the specified XML file.

void setDropDownViewResource(int dropDownLayout)

Sets the layout resource of the drop down views.

void setDropDownViewTheme(Resources.Theme theme)

Sets the Resources.Theme against which drop-down views are inflated.

void setViewResource(int layout)

Sets the layout resource of the item views.

Inherited methods

abstract void bindView(View view, Context context, Cursor cursor)

Bind an existing view to the data pointed to by cursor

void changeCursor(Cursor cursor)

Change the underlying cursor to a new cursor.

CharSequence convertToString(Cursor cursor)

Converts the cursor into a CharSequence.

int getCount()

How many items are in the data set represented by this Adapter.

Cursor getCursor()

Returns the cursor.

View getDropDownView(int position, View convertView, ViewGroup parent)

Gets a View that displays in the drop down popup the data at the specified position in the data set.

Resources.Theme getDropDownViewTheme()

Returns the value previously set by a call to setDropDownViewTheme(android.content.res.Resources.Theme).

Filter getFilter()

Returns a filter that can be used to constrain data with a filtering pattern.

FilterQueryProvider getFilterQueryProvider()

Returns the query filter provider used for filtering.

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.

View getView(int position, View convertView, ViewGroup parent)

Get a View that displays the data at the specified position in the data set.

boolean hasStableIds()

Indicates whether the item ids are stable across changes to the underlying data.

void init(Context context, Cursor c, boolean autoRequery)

This method was deprecated in API level 15. Don't use this, use the normal constructor. This will be removed in the future.

View newDropDownView(Context context, Cursor cursor, ViewGroup parent)

Makes a new drop down view to hold the data pointed to by cursor.

abstract View newView(Context context, Cursor cursor, ViewGroup parent)

Makes a new view to hold the data pointed to by cursor.

void onContentChanged()

Called when the ContentObserver on the cursor receives a change notification.

Cursor runQueryOnBackgroundThread(CharSequence constraint)

Runs a query with the specified constraint.

void setDropDownViewTheme(Resources.Theme theme)

Sets the Resources.Theme against which drop-down views are inflated.

void setFilterQueryProvider(FilterQueryProvider filterQueryProvider)

Sets the query filter provider used to filter the current Cursor.

Cursor swapCursor(Cursor newCursor)

Swap in a new Cursor, returning the old Cursor.

boolean areAllItemsEnabled()

Indicates whether all the items in this adapter are enabled.

CharSequence[] getAutofillOptions()

Gets a string representation of the adapter data that can help AutofillService autofill the view backed by the adapter.

View getDropDownView(int position, View convertView, ViewGroup parent)

Gets a View that displays in the drop down popup the data at the specified position in the data set.

int getItemViewType(int position)

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

int getViewTypeCount()

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

boolean hasStableIds()

Indicates whether the item ids are stable across changes to the underlying data.

boolean isEmpty()
boolean isEnabled(int position)

Returns true if the item at the specified position is not a separator.

void notifyDataSetChanged()

Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.

void notifyDataSetInvalidated()

Notifies the attached observers that the underlying data is no longer valid or available.

void registerDataSetObserver(DataSetObserver observer)

Register an observer that is called when changes happen to the data used by this adapter.

void setAutofillOptions(CharSequence... options)

Sets the value returned by getAutofillOptions()

void unregisterDataSetObserver(DataSetObserver observer)

Unregister an observer that has previously been registered with this adapter via registerDataSetObserver(DataSetObserver).

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 Filter getFilter()

Returns a filter that can be used to constrain data with a filtering pattern.

abstract Resources.Theme getDropDownViewTheme()

Returns the value previously set by a call to setDropDownViewTheme(android.content.res.Resources.Theme).

abstract void setDropDownViewTheme(Resources.Theme theme)

Sets the Resources.Theme against which drop-down views are inflated.

abstract boolean areAllItemsEnabled()

Indicates whether all the items in this adapter are enabled.

abstract boolean isEnabled(int position)

Returns true if the item at the specified position is not a separator.

abstract View getDropDownView(int position, View convertView, ViewGroup parent)

Gets a View that displays in the drop down popup the data at the specified position in the data set.

default CharSequence[] getAutofillOptions()

Gets a string representation of the adapter data that can help AutofillService autofill the view backed by the adapter.

abstract int getCount()

How many items are in the data set represented by this Adapter.

abstract Object getItem(int position)

Get the data item associated with the specified position in the data set.

abstract long getItemId(int position)

Get the row id associated with the specified position in the list.

abstract int getItemViewType(int position)

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

abstract View getView(int position, View convertView, ViewGroup parent)

Get a View that displays the data at the specified position in the data set.

abstract int getViewTypeCount()

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

abstract boolean hasStableIds()

Indicates whether the item ids are stable across changes to the underlying data.

abstract boolean isEmpty()
abstract void registerDataSetObserver(DataSetObserver observer)

Register an observer that is called when changes happen to the data used by this adapter.

abstract void unregisterDataSetObserver(DataSetObserver observer)

Unregister an observer that has previously been registered with this adapter via registerDataSetObserver(DataSetObserver).

Public constructors

ResourceCursorAdapter

Added in API level 1
public ResourceCursorAdapter (Context context, 
                int layout, 
                Cursor c)

This constructor is deprecated.
This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors. As an alternative, use LoaderManager with a CursorLoader.

Constructor the enables auto-requery.

Parameters
context Context: The context where the ListView associated with this adapter is running

layout int: resource identifier of a layout file that defines the views for this list item. Unless you override them later, this will define both the item views and the drop down views.

c Cursor

ResourceCursorAdapter

Added in API level 3
public ResourceCursorAdapter (Context context, 
                int layout, 
                Cursor c, 
                boolean autoRequery)

Constructor with default behavior as per CursorAdapter.CursorAdapter(Context, Cursor, boolean); it is recommended you not use this, but instead ResourceCursorAdapter(android.content.Context, int, android.database.Cursor, int). When using this constructor, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER will always be set.

Parameters
context Context: The context where the ListView associated with this adapter is running

layout int: resource identifier of a layout file that defines the views for this list item. Unless you override them later, this will define both the item views and the drop down views.

c Cursor: The cursor from which to get the data.

autoRequery boolean: If true the adapter will call requery() on the cursor whenever it changes so the most recent data is always displayed. Using true here is discouraged.

ResourceCursorAdapter

Added in API level 11
public ResourceCursorAdapter (Context context, 
                int layout, 
                Cursor c, 
                int flags)

Standard constructor.

Parameters
context Context: The context where the ListView associated with this adapter is running

layout int: Resource identifier of a layout file that defines the views for this list item. Unless you override them later, this will define both the item views and the drop down views.

c Cursor: The cursor from which to get the data.

flags int: Flags used to determine the behavior of the adapter, as per CursorAdapter.CursorAdapter(Context, Cursor, int).

Public methods

newDropDownView

Added in API level 1
public View newDropDownView (Context context, 
                Cursor cursor, 
                ViewGroup parent)

Makes a new drop down view to hold the data pointed to by cursor.

Parameters
context Context: Interface to application's global information

cursor Cursor: The cursor from which to get the data. The cursor is already moved to the correct position.

parent ViewGroup: The parent to which the new view is attached to

Returns
View the newly created view.

newView

Added in API level 1
public View newView (Context context, 
                Cursor cursor, 
                ViewGroup parent)

Inflates view(s) from the specified XML file.

Parameters
context Context: Interface to application's global information

cursor Cursor: The cursor from which to get the data. The cursor is already moved to the correct position.

parent ViewGroup: The parent to which the new view is attached to

Returns
View the newly created view.

setDropDownViewResource

Added in API level 1
public void setDropDownViewResource (int dropDownLayout)

Sets the layout resource of the drop down views.

Parameters
dropDownLayout int: the layout resources used to create drop down views

setDropDownViewTheme

Added in API level 23
public void setDropDownViewTheme (Resources.Theme theme)

Sets the Resources.Theme against which drop-down views are inflated.

By default, drop-down views are inflated against the theme of the Context passed to the adapter's constructor.

Parameters
theme Resources.Theme: the theme against which to inflate drop-down views or null to use the theme from the adapter's context

setViewResource

Added in API level 3
public void setViewResource (int layout)

Sets the layout resource of the item views.

Parameters
layout int: the layout resources used to create item views