SimpleCursorAdapter
open class SimpleCursorAdapter : ResourceCursorAdapter
| kotlin.Any | ||||
| ↳ | android.widget.BaseAdapter | |||
| ↳ | android.widget.CursorAdapter | |||
| ↳ | android.widget.ResourceCursorAdapter | |||
| ↳ | android.widget.SimpleCursorAdapter | |||
An easy adapter to map columns from a cursor to TextViews or ImageViews defined in an XML file. You can specify which columns you want, which views you want to display the columns, and the XML file that defines the appearance of these views. Binding occurs in two phases. First, if a android.widget.SimpleCursorAdapter.ViewBinder is available, ViewBinder.setViewValue(android.view.View,android.database.Cursor,int) is invoked. If the returned value is true, binding has occured. If the returned value is false and the view to bind is a TextView, setViewText(TextView,String) is invoked. If the returned value is false and the view to bind is an ImageView, setViewImage(ImageView,String) is invoked. If no appropriate binding can be found, an IllegalStateException is thrown. If this adapter is used with filtering, for instance in an android.widget.AutoCompleteTextView, you can use the android.widget.SimpleCursorAdapter.CursorToStringConverter and the android.widget.FilterQueryProvider interfaces to get control over the filtering process. You can refer to convertToString(android.database.Cursor) and runQueryOnBackgroundThread(CharSequence) for more information.
Summary
| Nested classes | |
|---|---|
| abstract |
This class can be used by external clients of SimpleCursorAdapter to define how the Cursor should be converted to a String. |
| abstract |
This class can be used by external clients of SimpleCursorAdapter to bind values fom the Cursor to views. |
| Inherited constants | |
|---|---|
| Public constructors | |
|---|---|
SimpleCursorAdapter(context: Context!, layout: Int, c: Cursor!, from: Array<String!>!, to: IntArray!)Constructor the enables auto-requery. |
|
SimpleCursorAdapter(context: Context!, layout: Int, c: Cursor!, from: Array<String!>!, to: IntArray!, flags: Int)Standard constructor. |
|
| Public methods | |
|---|---|
| open Unit |
Binds all of the field names passed into the "to" parameter of the constructor with their corresponding cursor columns as specified in the "from" parameter. |
| open Unit |
changeCursorAndColumns(c: Cursor!, from: Array<String!>!, to: IntArray!)Change the cursor and change the column-to-view mappings at the same time. |
| open CharSequence! |
convertToString(cursor: Cursor!)Returns a CharSequence representation of the specified Cursor as defined by the current CursorToStringConverter. |
| open SimpleCursorAdapter.CursorToStringConverter! |
Returns the converter used to convert the filtering Cursor into a String. |
| open Int |
Return the index of the column used to get a String representation of the Cursor. |
| open SimpleCursorAdapter.ViewBinder! |
Returns the |
| open Unit |
setCursorToStringConverter(cursorToStringConverter: SimpleCursorAdapter.CursorToStringConverter!)Sets the converter used to convert the filtering Cursor into a String. |
| open Unit |
setStringConversionColumn(stringConversionColumn: Int)Defines the index of the column in the Cursor used to get a String representation of that Cursor. |
| open Unit |
setViewBinder(viewBinder: SimpleCursorAdapter.ViewBinder!)Sets the binder used to bind data to views. |
| open Unit |
setViewImage(v: ImageView!, value: String!)Called by bindView() to set the image for an ImageView but only if there is no existing ViewBinder or if the existing ViewBinder cannot handle binding to an ImageView. |
| open Unit |
setViewText(v: TextView!, text: String!)Called by bindView() to set the text for a TextView but only if there is no existing ViewBinder or if the existing ViewBinder cannot handle binding to a TextView. |
| open Cursor! |
swapCursor(c: Cursor!)Swap in a new Cursor, returning the old Cursor. |
| Inherited functions | |
|---|---|
Public constructors
SimpleCursorAdapter
SimpleCursorAdapter(
context: Context!,
layout: Int,
c: Cursor!,
from: Array<String!>!,
to: IntArray!)
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.
SimpleCursorAdapter
SimpleCursorAdapter(
context: Context!,
layout: Int,
c: Cursor!,
from: Array<String!>!,
to: IntArray!,
flags: Int)
Standard constructor.
| Parameters | |
|---|---|
context |
Context!: The context where the ListView associated with this SimpleListItemFactory is running |
layout |
Int: resource identifier of a layout file that defines the views for this list item. The layout file should include at least those named views defined in "to" |
c |
Cursor!: The database cursor. Can be null if the cursor is not available yet. |
from |
Array<String!>!: A list of column names representing the data to bind to the UI. Can be null if the cursor is not available yet. |
to |
IntArray!: The views that should display column in the "from" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the from parameter. Can be null if the cursor is not available yet. |
flags |
Int: Flags used to determine the behavior of the adapter, as per CursorAdapter.CursorAdapter(Context,Cursor,int). |