CursorTreeAdapter
public abstract class CursorTreeAdapter
extends BaseExpandableListAdapter
implements Filterable
Known Direct Subclasses
|
Known Indirect Subclasses
|
将一系列Cursor
的数据公开给ExpandableListView
小部件的适配器。 顶层Cursor
(即在构造函数中给出)暴露组,而随后的Cursor
期从返回getChildrenCursor(Cursor)
暴露儿童的特定组内。 游标必须包含名为“_id”的列,否则此类将不起作用。
Summary
Public methods |
void |
changeCursor(Cursor cursor) |
String |
convertToString(Cursor cursor) |
Cursor |
getChild(int groupPosition, int childPosition) |
long |
getChildId(int groupPosition, int childPosition) |
View |
getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) |
int |
getChildrenCount(int groupPosition) |
Cursor |
getCursor() |
Filter |
getFilter() 返回可用于使用过滤模式约束数据的过滤器。 |
FilterQueryProvider |
getFilterQueryProvider() |
Cursor |
getGroup(int groupPosition) |
int |
getGroupCount() |
long |
getGroupId(int groupPosition) |
View |
getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) |
boolean |
hasStableIds() |
boolean |
isChildSelectable(int groupPosition, int childPosition) |
void |
notifyDataSetChanged() |
void |
notifyDataSetChanged(boolean releaseCursors) 通知数据集更改,但可以选择不释放任何缓存的游标。 |
void |
notifyDataSetInvalidated() |
void |
onGroupCollapsed(int groupPosition) 当一个组被折叠时调用。 |
Cursor |
runQueryOnBackgroundThread(CharSequence constraint) |
void |
setChildrenCursor(int groupPosition, Cursor childrenCursor) 为特定组设置子游标。 |
void |
setFilterQueryProvider(FilterQueryProvider filterQueryProvider) |
void |
setGroupCursor(Cursor cursor) 设置组光标。 |
Protected methods |
abstract void |
bindChildView(View view, Context context, Cursor cursor, boolean isLastChild) 将现有视图绑定到指针指向的子数据 |
abstract void |
bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) 将现有视图绑定到光标指向的组数据。 |
abstract Cursor |
getChildrenCursor(Cursor groupCursor) 获取给定组的孩子的光标。 |
abstract View |
newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent) 创建一个新的子视图来保存指针指向的数据。 |
abstract View |
newGroupView(Context context, Cursor cursor, boolean isExpanded, ViewGroup parent) 创建一个新的组视图来保存指针指向的组数据。 |
Public constructors
CursorTreeAdapter
CursorTreeAdapter (Cursor cursor,
Context context)
构造函数。 只要光标发生变化,适配器就会在光标上调用requery()
,以便始终显示最新的数据。
Parameters |
cursor |
Cursor : The cursor from which to get the data for the groups. |
context |
Context
|
CursorTreeAdapter
CursorTreeAdapter (Cursor cursor,
Context context,
boolean autoRequery)
构造函数。
Parameters |
cursor |
Cursor : The cursor from which to get the data for the groups. |
context |
Context : The context |
autoRequery |
boolean : If true the adapter will call requery() on the cursor whenever it changes so the most recent data is always displayed. |
Public methods
changeCursor
void changeCursor (Cursor cursor)
getChild
Cursor getChild (int groupPosition,
int childPosition)
Parameters |
groupPosition |
int
|
childPosition |
int
|
getChildId
long getChildId (int groupPosition,
int childPosition)
Parameters |
groupPosition |
int
|
childPosition |
int
|
getChildView
View getChildView (int groupPosition,
int childPosition,
boolean isLastChild,
View convertView,
ViewGroup parent)
Parameters |
groupPosition |
int
|
childPosition |
int
|
isLastChild |
boolean
|
convertView |
View
|
parent |
ViewGroup
|
getChildrenCount
int getChildrenCount (int groupPosition)
Parameters |
groupPosition |
int
|
getFilter
Filter getFilter ()
返回可用于使用过滤模式约束数据的过滤器。
这种方法通常由 Adapter
类实现。
Returns |
Filter |
a filter used to constrain data |
getGroup
Cursor getGroup (int groupPosition)
Parameters |
groupPosition |
int
|
getGroupCount
int getGroupCount ()
getGroupId
long getGroupId (int groupPosition)
Parameters |
groupPosition |
int
|
getGroupView
View getGroupView (int groupPosition,
boolean isExpanded,
View convertView,
ViewGroup parent)
Parameters |
groupPosition |
int
|
isExpanded |
boolean
|
convertView |
View
|
parent |
ViewGroup
|
hasStableIds
boolean hasStableIds ()
isChildSelectable
boolean isChildSelectable (int groupPosition,
int childPosition)
Parameters |
groupPosition |
int
|
childPosition |
int
|
notifyDataSetChanged
void notifyDataSetChanged ()
notifyDataSetChanged
void notifyDataSetChanged (boolean releaseCursors)
通知数据集更改,但可以选择不释放任何缓存的游标。
Parameters |
releaseCursors |
boolean : Whether to release and deactivate any cached cursors. |
notifyDataSetInvalidated
void notifyDataSetInvalidated ()
onGroupCollapsed
void onGroupCollapsed (int groupPosition)
Called when a group is collapsed.
Parameters |
groupPosition |
int : The group being collapsed. |
runQueryOnBackgroundThread
Cursor runQueryOnBackgroundThread (CharSequence constraint)
Parameters |
constraint |
CharSequence
|
setChildrenCursor
void setChildrenCursor (int groupPosition,
Cursor childrenCursor)
为特定组设置子游标。 如果有一个现有的游标,它将被关闭。
这在异步查询以防止阻止UI时非常有用。
Parameters |
groupPosition |
int : The group whose children are being set via this Cursor. |
childrenCursor |
Cursor : The Cursor that contains the children of the group. |
setFilterQueryProvider
void setFilterQueryProvider (FilterQueryProvider filterQueryProvider)
Parameters |
filterQueryProvider |
FilterQueryProvider
|
setGroupCursor
void setGroupCursor (Cursor cursor)
设置组光标。
Parameters |
cursor |
Cursor : The Cursor to set for the group. If there is an existing cursor it will be closed. |
Protected methods
bindChildView
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
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. |
newChildView
View newChildView (Context context,
Cursor cursor,
boolean isLastChild,
ViewGroup parent)
创建一个新的子视图来保存指针指向的数据。
Parameters |
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. |
parent |
ViewGroup : The parent to which the new view is attached to |
Returns |
View |
the newly created view. |
newGroupView
View newGroupView (Context context,
Cursor cursor,
boolean isExpanded,
ViewGroup parent)
创建一个新的组视图来保存指针指向的组数据。
Parameters |
context |
Context : Interface to application's global information |
cursor |
Cursor : The group cursor from which to get the data. The cursor is already moved to the correct position. |
isExpanded |
boolean : Whether the group is expanded. |
parent |
ViewGroup : The parent to which the new view is attached to |
Returns |
View |
The newly created view. |