Most visited

Recently visited

Added in API level 1

SimpleCursorTreeAdapter

public abstract class SimpleCursorTreeAdapter
extends ResourceCursorTreeAdapter

java.lang.Object
   ↳ android.widget.BaseExpandableListAdapter
     ↳ android.widget.CursorTreeAdapter
       ↳ android.widget.ResourceCursorTreeAdapter
         ↳ android.widget.SimpleCursorTreeAdapter


一个简单的适配器,可将游标中的列映射到XML文件中定义的TextView或ImageView。 您可以指定所需的列,要显示列的视图以及定义这些视图外观的XML文件。 为孩子和组分离XML文件是可能的。 绑定发生在两个阶段。 首先,如果有SimpleCursorTreeAdapter.ViewBinder可用,则调用setViewValue(android.view.View, android.database.Cursor, int) 如果返回值为true,则发生绑定。 如果返回值为false,并且要绑定的视图是TextView,则调用setViewText(TextView, String) 如果返回值为false,并且要绑定的视图是ImageView,则调用setViewImage(ImageView, String) 如果找不到合适的绑定, IllegalStateException抛出IllegalStateException

Summary

Nested classes

interface SimpleCursorTreeAdapter.ViewBinder

SimpleCursorTreeAdapter的外部客户端可以使用此类将Cursor中的值绑定到视图。

Public constructors

SimpleCursorTreeAdapter(Context context, Cursor cursor, int collapsedGroupLayout, int expandedGroupLayout, String[] groupFrom, int[] groupTo, int childLayout, int lastChildLayout, String[] childFrom, int[] childTo)

构造函数。

SimpleCursorTreeAdapter(Context context, Cursor cursor, int collapsedGroupLayout, int expandedGroupLayout, String[] groupFrom, int[] groupTo, int childLayout, String[] childFrom, int[] childTo)

构造函数。

SimpleCursorTreeAdapter(Context context, Cursor cursor, int groupLayout, String[] groupFrom, int[] groupTo, int childLayout, String[] childFrom, int[] childTo)

构造函数。

Public methods

SimpleCursorTreeAdapter.ViewBinder getViewBinder()

返回用于将数据绑定到视图的 SimpleCursorTreeAdapter.ViewBinder

void setViewBinder(SimpleCursorTreeAdapter.ViewBinder viewBinder)

设置用于将数据绑定到视图的联编程序。

void setViewText(TextView v, String text)

只有在没有现有的ViewBinder或现有ViewBinder无法处理与TextView的绑定时,才由bindView()调用以设置TextView的文本。

Protected methods

void bindChildView(View view, Context context, Cursor cursor, boolean isLastChild)

将现有视图绑定到指针指向的子数据

void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded)

将现有视图绑定到光标指向的组数据。

void setViewImage(ImageView v, String value)

由bindView()调用以设置ImageView的图像。

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.Filterable
From interface android.widget.ExpandableListAdapter
From interface android.widget.HeterogeneousExpandableList

Public constructors

SimpleCursorTreeAdapter

Added in API level 1
SimpleCursorTreeAdapter (Context context, 
                Cursor cursor, 
                int collapsedGroupLayout, 
                int expandedGroupLayout, 
                String[] groupFrom, 
                int[] groupTo, 
                int childLayout, 
                int lastChildLayout, 
                String[] childFrom, 
                int[] childTo)

构造函数。

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 String: A list of column names that will be used to display the data for a group.
groupTo int: 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 String: A list of column names that will be used to display the data for a child.
childTo int: 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, 
                int collapsedGroupLayout, 
                int expandedGroupLayout, 
                String[] groupFrom, 
                int[] groupTo, 
                int childLayout, 
                String[] childFrom, 
                int[] childTo)

构造函数。

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 String: A list of column names that will be used to display the data for a group.
groupTo int: 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 String: A list of column names that will be used to display the data for a child.
childTo int: 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, 
                int groupLayout, 
                String[] groupFrom, 
                int[] groupTo, 
                int childLayout, 
                String[] childFrom, 
                int[] childTo)

构造函数。

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 String: A list of column names that will be used to display the data for a group.
groupTo int: 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 String: A list of column names that will be used to display the data for a child.
childTo int: 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
SimpleCursorTreeAdapter.ViewBinder getViewBinder ()

返回用于将数据绑定到视图的 SimpleCursorTreeAdapter.ViewBinder

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

也可以看看:

setViewBinder

Added in API level 5
void setViewBinder (SimpleCursorTreeAdapter.ViewBinder viewBinder)

设置用于将数据绑定到视图的联编程序。

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

也可以看看:

setViewText

Added in API level 5
void setViewText (TextView v, 
                String text)

只有在没有现有的ViewBinder或现有ViewBinder无法处理与TextView的绑定时,才由bindView()调用以设置TextView的文本。 意图被需要过滤从数据库检索的字符串的适配器覆盖。

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
void bindChildView (View view, 
                Context context, 
                Cursor cursor, 
                boolean isLastChild)

将现有视图绑定到指针指向的子数据

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
void bindGroupView (View view, 
                Context context, 
                Cursor cursor, 
                boolean isExpanded)

将现有视图绑定到光标指向的组数据。

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
void setViewImage (ImageView v, 
                String value)

由bindView()调用以设置ImageView的图像。 默认情况下,该值将被视为Uri。 意图被需要过滤从数据库检索的字符串的适配器覆盖。

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

Hooray!