Added in API level 1

ResourceCursorAdapter


abstract class ResourceCursorAdapter : CursorAdapter
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

If set the adapter will call requery() on the cursor whenever a content change notification is delivered. Implies FLAG_REGISTER_CONTENT_OBSERVER.

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. Be careful when using this flag: you will need to unset the current Cursor from the adapter to avoid leaks due to its registered observers. This flag is not needed when using a CursorAdapter with a android.content.CursorLoader.

Public constructors
ResourceCursorAdapter(context: Context!, layout: Int, c: Cursor!)

Constructor the enables auto-requery.

ResourceCursorAdapter(context: Context!, layout: Int, c: Cursor!, autoRequery: Boolean)

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!, layout: Int, c: Cursor!, flags: Int)

Standard constructor.

Public methods
open View!
newDropDownView(context: Context!, cursor: Cursor!, parent: ViewGroup!)

open View!
newView(context: Context!, cursor: Cursor!, parent: ViewGroup!)

Inflates view(s) from the specified XML file.

open Unit
setDropDownViewResource(dropDownLayout: Int)

Sets the layout resource of the drop down views.

open Unit

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

open Unit

Sets the layout resource of the item views.

Inherited functions
Boolean areAllItemsEnabled()

Array<CharSequence!>? getAutofillOptions()

Int getItemViewType(position: Int)

Int getViewTypeCount()

Boolean isEmpty()

Boolean isEnabled(position: Int)

Unit notifyDataSetChanged()

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

Unit notifyDataSetInvalidated()

Notifies the attached observers that the underlying data is no longer valid or available. Once invoked this adapter is no longer valid and should not report further data set changes.

Unit registerDataSetObserver(observer: DataSetObserver!)

Unit setAutofillOptions(vararg options: CharSequence!)

Sets the value returned by getAutofillOptions()

Unit unregisterDataSetObserver(observer: DataSetObserver!)

Unit bindView(view: View!, context: Context!, cursor: Cursor!)

Bind an existing view to the data pointed to by cursor

Unit changeCursor(cursor: Cursor!)

Change the underlying cursor to a new cursor. If there is an existing cursor it will be closed.

CharSequence! convertToString(cursor: Cursor!)

Converts the cursor into a CharSequence. Subclasses should override this method to convert their results. The default implementation returns an empty String for null values or the default String representation of the value.

Int getCount()

Cursor! getCursor()

Returns the cursor.

View! getDropDownView(position: Int, convertView: View!, parent: ViewGroup!)

Resources.Theme? getDropDownViewTheme()

Filter! getFilter()

FilterQueryProvider! getFilterQueryProvider()

Returns the query filter provider used for filtering. When the provider is null, no filtering occurs.

Any! getItem(position: Int)

Long getItemId(position: Int)

View! getView(position: Int, convertView: View!, parent: ViewGroup!)

Boolean hasStableIds()

Unit init(context: Context!, c: Cursor!, autoRequery: Boolean)

Unit onContentChanged()

Called when the ContentObserver on the cursor receives a change notification. The default implementation provides the auto-requery logic, but may be overridden by sub classes.

Cursor! runQueryOnBackgroundThread(constraint: CharSequence!)

Runs a query with the specified constraint. This query is requested by the filter attached to this adapter. The query is provided by a android.widget.FilterQueryProvider. If no provider is specified, the current cursor is not filtered and returned. After this method returns the resulting cursor is passed to changeCursor(android.database.Cursor) and the previous cursor is closed. This method is always executed on a background thread, not on the application's main thread (or UI thread.) Contract: when constraint is null or empty, the original results, prior to any filtering, must be returned.
This method may take several seconds to complete, so it should only be called from a worker thread.

Unit setFilterQueryProvider(filterQueryProvider: FilterQueryProvider!)

Sets the query filter provider used to filter the current Cursor. The provider's android.widget.FilterQueryProvider#runQuery(CharSequence) method is invoked when filtering is requested by a client of this adapter.

Cursor! swapCursor(newCursor: Cursor!)

Swap in a new Cursor, returning the old Cursor. Unlike changeCursor(android.database.Cursor), the returned old Cursor is not closed.

Public constructors

ResourceCursorAdapter

Added in API level 1
ResourceCursorAdapter(
    context: Context!,
    layout: Int,
    c: Cursor!)

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 android.app.LoaderManager with a android.content.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.

ResourceCursorAdapter

Added in API level 3
ResourceCursorAdapter(
    context: Context!,
    layout: Int,
    c: Cursor!,
    autoRequery: Boolean)

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, 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
ResourceCursorAdapter(
    context: Context!,
    layout: Int,
    c: Cursor!,
    flags: Int)

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
open fun newDropDownView(
    context: Context!,
    cursor: Cursor!,
    parent: ViewGroup!
): View!
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
Return
View! the newly created view.

newView

Added in API level 1
open fun newView(
    context: Context!,
    cursor: Cursor!,
    parent: ViewGroup!
): View!

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
Return
View! the newly created view.

setDropDownViewResource

Added in API level 1
open fun setDropDownViewResource(dropDownLayout: Int): Unit

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
open fun setDropDownViewTheme(theme: Resources.Theme?): Unit

Sets the android.content.res.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
open fun setViewResource(layout: Int): Unit

Sets the layout resource of the item views.

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