Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

ResourceCursorAdapter

public abstract class ResourceCursorAdapter
extends CursorAdapter

java.lang.Object
   ↳ android.widget.BaseAdapter
     ↳ android.widget.CursorAdapter
       ↳ android.widget.ResourceCursorAdapter


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

Public constructors

ResourceCursorAdapter(Context context, int layout, Cursor c)

This constructor was deprecated in API level 11. 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(Context, int, 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

Public constructors

ResourceCursorAdapter

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

This constructor was deprecated in API level 11.
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(Context, int, 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