SimpleCursorAdapter
class SimpleCursorAdapter : ResourceCursorAdapter
| kotlin.Any | ||||
| ↳ | android.widget.BaseAdapter | |||
| ↳ | androidx.cursoradapter.widget.CursorAdapter | |||
| ↳ | androidx.cursoradapter.widget.ResourceCursorAdapter | |||
| ↳ | androidx.cursoradapter.widget.SimpleCursorAdapter |
Static library support version of the framework's android.widget.SimpleCursorAdapter. 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
Nested types |
|---|
|
This class can be used by external clients of SimpleCursorAdapter to define how the Cursor should be converted to a String. |
interface SimpleCursorAdapter.ViewBinderThis class can be used by external clients of SimpleCursorAdapter to bind values fom the Cursor to views. |
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. |
SimpleCursorAdapter(Standard constructor. |
Public functions |
|
|---|---|
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. |
Unit |
changeCursorAndColumns(c: Cursor!, from: Array<String!>!, to: IntArray!)Change the cursor and change the column-to-view mappings at the same time. |
CharSequence! |
convertToString(cursor: Cursor!)Returns a CharSequence representation of the specified Cursor as defined by the current CursorToStringConverter. |
SimpleCursorAdapter.CursorToStringConverter! |
Returns the converter used to convert the filtering Cursor into a String. |
Int |
Return the index of the column used to get a String representation of the Cursor. |
SimpleCursorAdapter.ViewBinder! |
Returns the |
Unit |
setCursorToStringConverter(Sets the converter used to convert the filtering Cursor into a String. |
Unit |
setStringConversionColumn(stringConversionColumn: Int)Defines the index of the column in the Cursor used to get a String representation of that Cursor. |
Unit |
setViewBinder(viewBinder: SimpleCursorAdapter.ViewBinder!)Sets the binder used to bind data to views. |
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. |
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. |
Cursor! |
swapCursor(newCursor: Cursor!)Swap in a new Cursor, returning the old Cursor. |
Inherited Constants |
||||
|---|---|---|---|---|
|
||||
|
Inherited functions |
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
Public constructors
SimpleCursorAdapter(
context: Context!,
layout: Int,
c: Cursor!,
from: Array<String!>!,
to: IntArray!
)
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 |
Public functions
bindView
fun bindView(view: View!, context: Context!, cursor: Cursor!): 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. Binding occurs in two phases. First, if a android.widget.SimpleCursorAdapter.ViewBinder is available, setViewValue 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 is invoked. If the returned value is false and the view to bind is an ImageView, setViewImage is invoked. If no appropriate binding can be found, an IllegalStateException is thrown.
| Throws | |
|---|---|
java.lang.IllegalStateException |
if binding cannot occur |
changeCursorAndColumns
fun changeCursorAndColumns(c: Cursor!, from: Array<String!>!, to: IntArray!): Unit
Change the cursor and change the column-to-view mappings at the same time.
| Parameters | |
|---|---|
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. |
convertToString
fun convertToString(cursor: Cursor!): CharSequence!
Returns a CharSequence representation of the specified Cursor as defined by the current CursorToStringConverter. If no CursorToStringConverter has been set, the String conversion column is used instead. If the conversion column is -1, the returned String is empty if the cursor is null or Cursor.toString().
| Parameters | |
|---|---|
cursor: Cursor! |
the Cursor to convert to a CharSequence |
| Returns | |
|---|---|
CharSequence! |
a non-null CharSequence representing the cursor |
getCursorToStringConverter
fun getCursorToStringConverter(): SimpleCursorAdapter.CursorToStringConverter!
Returns the converter used to convert the filtering Cursor into a String.
| Returns | |
|---|---|
SimpleCursorAdapter.CursorToStringConverter! |
null if the converter does not exist or an instance of |
getStringConversionColumn
fun getStringConversionColumn(): Int
Return the index of the column used to get a String representation of the Cursor.
| Returns | |
|---|---|
Int |
a valid index in the current Cursor or -1 |
getViewBinder
fun getViewBinder(): SimpleCursorAdapter.ViewBinder!
Returns the ViewBinder used to bind data to views.
| Returns | |
|---|---|
SimpleCursorAdapter.ViewBinder! |
a ViewBinder or null if the binder does not exist |
| See also | |
|---|---|
bindView |
|
setViewBinder |
setCursorToStringConverter
fun setCursorToStringConverter(
cursorToStringConverter: SimpleCursorAdapter.CursorToStringConverter!
): Unit
Sets the converter used to convert the filtering Cursor into a String.
| Parameters | |
|---|---|
cursorToStringConverter: SimpleCursorAdapter.CursorToStringConverter! |
the Cursor to String converter, or null to remove the converter |
setStringConversionColumn
fun setStringConversionColumn(stringConversionColumn: Int): Unit
Defines the index of the column in the Cursor used to get a String representation of that Cursor. The column is used to convert the Cursor to a String only when the current CursorToStringConverter is null.
| Parameters | |
|---|---|
stringConversionColumn: Int |
a valid index in the current Cursor or -1 to use the default conversion mechanism |
setViewBinder
fun setViewBinder(viewBinder: SimpleCursorAdapter.ViewBinder!): Unit
Sets the binder used to bind data to views.
| Parameters | |
|---|---|
viewBinder: SimpleCursorAdapter.ViewBinder! |
the binder used to bind data to views, can be null to remove the existing binder |
| See also | |
|---|---|
bindView |
|
getViewBinder |
setViewImage
fun setViewImage(v: ImageView!, value: String!): Unit
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. By default, the value will be treated as an image resource. If the value cannot be used as an image resource, the value is used as an image Uri. Intended to be overridden by Adapters that need to filter strings retrieved from the database.
setViewText
fun setViewText(v: TextView!, text: String!): Unit
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. Intended to be overridden by Adapters that need to filter strings retrieved from the database.
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. |