Added in API level 1

SimpleCursorTreeAdapter


abstract class SimpleCursorTreeAdapter : ResourceCursorTreeAdapter
kotlin.Any
   ↳ android.widget.BaseExpandableListAdapter
   ↳ android.widget.CursorTreeAdapter
   ↳ android.widget.ResourceCursorTreeAdapter
   ↳ android.widget.SimpleCursorTreeAdapter

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. Separate XML files for child and groups are possible. Binding occurs in two phases. First, if a android.widget.SimpleCursorTreeAdapter.ViewBinder is available, ViewBinder#setViewValue(android.view.View, android.database.Cursor, int) is invoked. If the returned value is true, binding has occurred. If the returned value is false and the view to bind is a TextView, setViewText(android.widget.TextView,java.lang.String) is invoked. If the returned value is false and the view to bind is an ImageView, setViewImage(android.widget.ImageView,java.lang.String) is invoked. If no appropriate binding can be found, an IllegalStateException is thrown.

Summary

Nested classes
abstract

This class can be used by external clients of SimpleCursorTreeAdapter to bind values from the Cursor to views.

Public constructors
SimpleCursorTreeAdapter(context: Context!, cursor: Cursor!, collapsedGroupLayout: Int, expandedGroupLayout: Int, groupFrom: Array<String!>!, groupTo: IntArray!, childLayout: Int, lastChildLayout: Int, childFrom: Array<String!>!, childTo: IntArray!)

Constructor.

SimpleCursorTreeAdapter(context: Context!, cursor: Cursor!, collapsedGroupLayout: Int, expandedGroupLayout: Int, groupFrom: Array<String!>!, groupTo: IntArray!, childLayout: Int, childFrom: Array<String!>!, childTo: IntArray!)

Constructor.

SimpleCursorTreeAdapter(context: Context!, cursor: Cursor!, groupLayout: Int, groupFrom: Array<String!>!, groupTo: IntArray!, childLayout: Int, childFrom: Array<String!>!, childTo: IntArray!)

Constructor.

Public methods
open SimpleCursorTreeAdapter.ViewBinder!

Returns the ViewBinder used to bind data to views.

open Unit

Sets the binder used to bind data to views.

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.

Protected methods
open Unit
bindChildView(view: View!, context: Context!, cursor: Cursor!, isLastChild: Boolean)

open Unit
bindGroupView(view: View!, context: Context!, cursor: Cursor!, isExpanded: Boolean)

open Unit
setViewImage(v: ImageView!, value: String!)

Called by bindView() to set the image for an ImageView.

Inherited functions

Public constructors

SimpleCursorTreeAdapter

Added in API level 1
SimpleCursorTreeAdapter(
    context: Context!,
    cursor: Cursor!,
    collapsedGroupLayout: Int,
    expandedGroupLayout: Int,
    groupFrom: Array<String!>!,
    groupTo: IntArray!,
    childLayout: Int,
    lastChildLayout: Int,
    childFrom: Array<String!>!,
    childTo: IntArray!)

Constructor.

Parameters
context Context!: The context where the ExpandableListView associated with this SimpleCursorTreeAdapter is running
cursor Cursor!: The database cursor
collapsedGroupLayout Int: The resource identifier of a layout file that defines the views for a collapsed group. The layout file should include at least those named views defined in groupTo.
expandedGroupLayout Int: The resource identifier of a layout file that defines the views for an expanded group. The layout file should include at least those named views defined in groupTo.
groupFrom Array<String!>!: A list of column names that will be used to display the data for a group.
groupTo IntArray!: The group views (from the group layouts) that should display column in the "from" parameter. These should all be TextViews or ImageViews. The first N views in this list are given the values of the first N columns in the from parameter.
childLayout Int: The resource identifier of a layout file that defines the views for a child (except the last). The layout file should include at least those named views defined in childTo.
lastChildLayout Int: The resource identifier of a layout file that defines the views for the last child within a group. The layout file should include at least those named views defined in childTo.
childFrom Array<String!>!: A list of column names that will be used to display the data for a child.
childTo IntArray!: The child views (from the child layouts) that should display column in the "from" parameter. These should all be TextViews or ImageViews. The first N views in this list are given the values of the first N columns in the from parameter.

SimpleCursorTreeAdapter

Added in API level 1
SimpleCursorTreeAdapter(
    context: Context!,
    cursor: Cursor!,
    collapsedGroupLayout: Int,
    expandedGroupLayout: Int,
    groupFrom: Array<String!>!,
    groupTo: IntArray!,
    childLayout: Int,
    childFrom: Array<String!>!,
    childTo: IntArray!)

Constructor.

Parameters
context Context!: The context where the ExpandableListView associated with this SimpleCursorTreeAdapter is running
cursor Cursor!: The database cursor
collapsedGroupLayout Int: The resource identifier of a layout file that defines the views for a collapsed group. The layout file should include at least those named views defined in groupTo.
expandedGroupLayout Int: The resource identifier of a layout file that defines the views for an expanded group. The layout file should include at least those named views defined in groupTo.
groupFrom Array<String!>!: A list of column names that will be used to display the data for a group.
groupTo IntArray!: The group views (from the group layouts) that should display column in the "from" parameter. These should all be TextViews or ImageViews. The first N views in this list are given the values of the first N columns in the from parameter.
childLayout Int: The resource identifier of a layout file that defines the views for a child. The layout file should include at least those named views defined in childTo.
childFrom Array<String!>!: A list of column names that will be used to display the data for a child.
childTo IntArray!: The child views (from the child layouts) that should display column in the "from" parameter. These should all be TextViews or ImageViews. The first N views in this list are given the values of the first N columns in the from parameter.

SimpleCursorTreeAdapter

Added in API level 1
SimpleCursorTreeAdapter(
    context: Context!,
    cursor: Cursor!,
    groupLayout: Int,
    groupFrom: Array<String!>!,
    groupTo: IntArray!,
    childLayout: Int,
    childFrom: Array<String!>!,
    childTo: IntArray!)

Constructor.

Parameters
context Context!: The context where the ExpandableListView associated with this SimpleCursorTreeAdapter is running
cursor Cursor!: The database cursor
groupLayout Int: The resource identifier of a layout file that defines the views for a group. The layout file should include at least those named views defined in groupTo.
groupFrom Array<String!>!: A list of column names that will be used to display the data for a group.
groupTo IntArray!: The group views (from the group layouts) that should display column in the "from" parameter. These should all be TextViews or ImageViews. The first N views in this list are given the values of the first N columns in the from parameter.
childLayout Int: The resource identifier of a layout file that defines the views for a child. The layout file should include at least those named views defined in childTo.
childFrom Array<String!>!: A list of column names that will be used to display the data for a child.
childTo IntArray!: The child views (from the child layouts) that should display column in the "from" parameter. These should all be TextViews or ImageViews. The first N views in this list are given the values of the first N columns in the from parameter.

Public methods

getViewBinder

Added in API level 5
open fun getViewBinder(): SimpleCursorTreeAdapter.ViewBinder!

Returns the ViewBinder used to bind data to views.

Return
SimpleCursorTreeAdapter.ViewBinder! a ViewBinder or null if the binder does not exist

setViewBinder

Added in API level 5
open fun setViewBinder(viewBinder: SimpleCursorTreeAdapter.ViewBinder!): Unit

Sets the binder used to bind data to views.

Parameters
viewBinder SimpleCursorTreeAdapter.ViewBinder!: the binder used to bind data to views, can be null to remove the existing binder

See Also

setViewText

Added in API level 5
open 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.

Parameters
v TextView!: TextView to receive text
text String!: the text to be set for the TextView

Protected methods

bindChildView

Added in API level 1
protected open fun bindChildView(
    view: View!,
    context: Context!,
    cursor: Cursor!,
    isLastChild: Boolean
): Unit
Parameters
view View!: Existing view, returned earlier by newChildView
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.
isLastChild Boolean: Whether the child is the last child within its group.

bindGroupView

Added in API level 1
protected open fun bindGroupView(
    view: View!,
    context: Context!,
    cursor: Cursor!,
    isExpanded: Boolean
): Unit
Parameters
view View!: Existing view, returned earlier by newGroupView.
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.
isExpanded Boolean: Whether the group is expanded.

setViewImage

Added in API level 1
protected open fun setViewImage(
    v: ImageView!,
    value: String!
): Unit

Called by bindView() to set the image for an ImageView. By default, the value will be treated as a Uri. Intended to be overridden by Adapters that need to filter strings retrieved from the database.

Parameters
v ImageView!: ImageView to receive an image
value String!: the value retrieved from the cursor