CursorAdapter
abstract class CursorAdapter : BaseAdapter, Filterable
ResourceCursorAdapter |
Static library support version of the framework's |
SimpleCursorAdapter |
Static library support version of the framework's |
Static library support version of the framework's android.widget.CursorAdapter. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview.
Summary
Constants |
|
|---|---|
const Int |
This property 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. |
const Int |
If set the adapter will register a content observer on the cursor and will call |
Public constructors |
|---|
This function 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. |
CursorAdapter(context: Context!, c: Cursor!, autoRequery: Boolean)Constructor that allows control over auto-requery. |
CursorAdapter(context: Context!, c: Cursor!, flags: Int)Recommended constructor. |
Public functions |
|
|---|---|
abstract Unit |
Bind an existing view to the data pointed to by cursor |
Unit |
changeCursor(cursor: Cursor!)Change the underlying cursor to a new cursor. |
CharSequence! |
convertToString(cursor: Cursor!)Converts the cursor into a CharSequence. |
Int |
getCount() |
Cursor! |
Returns the cursor. |
View! |
getDropDownView(position: Int, convertView: View!, parent: ViewGroup!) |
Filter! |
|
FilterQueryProvider! |
Returns the query filter provider used for filtering. |
Any! |
|
Long |
|
View! |
|
Boolean |
|
View! |
newDropDownView(context: Context!, cursor: Cursor!, parent: ViewGroup!)Makes a new drop down view to hold the data pointed to by cursor. |
abstract View! |
Makes a new view to hold the data pointed to by cursor. |
Cursor! |
runQueryOnBackgroundThread(constraint: CharSequence!)Runs a query with the specified constraint. |
Unit |
setFilterQueryProvider(filterQueryProvider: FilterQueryProvider!)Sets the query filter provider used to filter the current Cursor. |
Cursor! |
swapCursor(newCursor: Cursor!)Swap in a new Cursor, returning the old Cursor. |
Protected functions |
|
|---|---|
Unit |
This function is deprecated. Don't use this, use the normal constructor. |
Unit |
Called when the |
Inherited Constants |
||||
|---|---|---|---|---|
|
Inherited functions |
||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Constants
const val FLAG_AUTO_REQUERY = 1: Int
If set the adapter will call requery() on the cursor whenever a content change notification is delivered. Implies FLAG_REGISTER_CONTENT_OBSERVER.
FLAG_REGISTER_CONTENT_OBSERVER
const val FLAG_REGISTER_CONTENT_OBSERVER = 2: Int
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
CursorAdapter
CursorAdapter(context: Context!, c: Cursor!, autoRequery: Boolean)
Constructor that allows control over auto-requery. It is recommended you not use this, but instead CursorAdapter. When using this constructor, FLAG_REGISTER_CONTENT_OBSERVER will always be set.
CursorAdapter
CursorAdapter(context: Context!, c: Cursor!, flags: Int)
Recommended constructor.
| Parameters | |
|---|---|
context: Context! |
The context |
c: Cursor! |
The cursor from which to get the data. |
flags: Int |
Flags used to determine the behavior of the adapter; may be any combination of |
Public functions
bindView
abstract fun bindView(view: View!, context: Context!, cursor: Cursor!): Unit
Bind an existing view to the data pointed to by cursor
changeCursor
fun changeCursor(cursor: Cursor!): Unit
Change the underlying cursor to a new cursor. If there is an existing cursor it will be closed.
| Parameters | |
|---|---|
cursor: Cursor! |
The new cursor to be used |
convertToString
fun convertToString(cursor: Cursor!): CharSequence!
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.
| Parameters | |
|---|---|
cursor: Cursor! |
the cursor to convert to a CharSequence |
| Returns | |
|---|---|
CharSequence! |
a CharSequence representing the value |
getFilterQueryProvider
fun getFilterQueryProvider(): FilterQueryProvider!
Returns the query filter provider used for filtering. When the provider is null, no filtering occurs.
| Returns | |
|---|---|
FilterQueryProvider! |
the current filter query provider or null if it does not exist |
getView
fun getView(position: Int, convertView: View!, parent: ViewGroup!): View!
| See also | |
|---|---|
getView |
newDropDownView
fun newDropDownView(context: Context!, cursor: Cursor!, parent: ViewGroup!): View!
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
abstract fun newView(context: Context!, cursor: Cursor!, parent: ViewGroup!): View!
Makes a new 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. |
runQueryOnBackgroundThread
fun runQueryOnBackgroundThread(constraint: CharSequence!): Cursor!
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 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.
| Parameters | |
|---|---|
constraint: CharSequence! |
the constraint with which the query must be filtered |
| Returns | |
|---|---|
Cursor! |
a Cursor representing the results of the new query |
setFilterQueryProvider
fun setFilterQueryProvider(filterQueryProvider: FilterQueryProvider!): Unit
Sets the query filter provider used to filter the current Cursor. The provider's runQuery method is invoked when filtering is requested by a client of this adapter.
| Parameters | |
|---|---|
filterQueryProvider: FilterQueryProvider! |
the filter query provider or null to remove it |
swapCursor
fun swapCursor(newCursor: Cursor!): Cursor!
Swap in a new Cursor, returning the old Cursor. Unlike changeCursor, the returned old Cursor is not closed.
| Parameters | |
|---|---|
newCursor: Cursor! |
The new cursor to be used. |
| Returns | |
|---|---|
Cursor! |
Returns the previously set Cursor, or null if there was not one. If the given new Cursor is the same instance is the previously set Cursor, null is also returned. |
Protected functions
onContentChanged
protected fun onContentChanged(): Unit
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.
| See also | |
|---|---|
onChange |