java.lang.Object | ||||
↳ | 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
SimpleCursorTreeAdapter.ViewBinder
is available,
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(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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
SimpleCursorTreeAdapter.ViewBinder | This class can be used by external clients of SimpleCursorTreeAdapter to bind values from the Cursor to views. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Constructor.
|
||||||||||
|
Constructor.
|
||||||||||
|
Constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Returns the
SimpleCursorTreeAdapter.ViewBinder
used to bind data to views.
|
||||||||||
|
Sets the binder used to bind data to views.
|
||||||||||
|
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Bind an existing view to the child data pointed to by cursor
|
||||||||||
|
Bind an existing view to the group data pointed to by cursor.
|
||||||||||
|
Called by bindView() to set the image for an ImageView.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.widget.ResourceCursorTreeAdapter
|
|||||||||||
From class
android.widget.CursorTreeAdapter
|
|||||||||||
From class
android.widget.BaseExpandableListAdapter
|
|||||||||||
From class
java.lang.Object
|
|||||||||||
From interface
android.widget.ExpandableListAdapter
|
|||||||||||
From interface
android.widget.Filterable
|
|||||||||||
From interface
android.widget.HeterogeneousExpandableList
|
Constructor.
context |
The context where the
ExpandableListView
associated with this
SimpleCursorTreeAdapter
is
running
|
---|---|
cursor | The database cursor |
collapsedGroupLayout | 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 | 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 | A list of column names that will be used to display the data for a group. |
groupTo | 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 | 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 | 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 | A list of column names that will be used to display the data for a child. |
childTo | 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. |
Constructor.
context |
The context where the
ExpandableListView
associated with this
SimpleCursorTreeAdapter
is
running
|
---|---|
cursor | The database cursor |
collapsedGroupLayout | 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 | 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 | A list of column names that will be used to display the data for a group. |
groupTo | 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 | 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 | A list of column names that will be used to display the data for a child. |
childTo | 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. |
Constructor.
context |
The context where the
ExpandableListView
associated with this
SimpleCursorTreeAdapter
is
running
|
---|---|
cursor | The database cursor |
groupLayout | 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 | A list of column names that will be used to display the data for a group. |
groupTo | 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 | 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 | A list of column names that will be used to display the data for a child. |
childTo | 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. |
Returns the
SimpleCursorTreeAdapter.ViewBinder
used to bind data to views.
Sets the binder used to bind data to views.
viewBinder | the binder used to bind data to views, can be null to remove the existing binder |
---|
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.
v | TextView to receive text |
---|---|
text | the text to be set for the TextView |
Bind an existing view to the child data pointed to by cursor
view | Existing view, returned earlier by newChildView |
---|---|
context | Interface to application's global information |
cursor | The cursor from which to get the data. The cursor is already moved to the correct position. |
isLastChild | Whether the child is the last child within its group. |
Bind an existing view to the group data pointed to by cursor.
view | Existing view, returned earlier by newGroupView. |
---|---|
context | Interface to application's global information |
cursor | The cursor from which to get the data. The cursor is already moved to the correct position. |
isExpanded | Whether the group is expanded. |
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.
v | ImageView to receive an image |
---|---|
value | the value retrieved from the cursor |