SimpleExpandableListAdapter
public class SimpleExpandableListAdapter
extends BaseExpandableListAdapter
一个简单的适配器,可将静态数据映射到XML文件中定义的组和子视图。 您可以单独指定支持该组的数据作为地图列表。 ArrayList中的每个条目都对应于展开列表中的一个组。 地图包含每行的数据。 您还可以指定一个XML文件,该文件定义用于显示组的视图以及从映射中的键到特定视图的映射。 这个过程对于一个孩子来说是相似的,除了它是更深一层的,所以数据支持被指定为一个List
>,其中第一个列表对应于孩子的组,第二个列表对应于组内孩子的位置,最后地图保存该特定孩子的数据。
Summary
Public constructors |
SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int groupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, String[] childFrom, int[] childTo) 构造函数 |
SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, String[] childFrom, int[] childTo) 构造函数 |
SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, int lastChildLayout, String[] childFrom, int[] childTo) 构造函数 |
Public methods |
Object |
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) |
Object |
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) |
View |
newChildView(boolean isLastChild, ViewGroup parent) 为一个孩子实例化一个新的View。 |
View |
newGroupView(boolean isExpanded, ViewGroup parent) 实例化组的新视图。 |
Public constructors
SimpleExpandableListAdapter
SimpleExpandableListAdapter (Context context,
List<? extends Map<String, ?>> groupData,
int groupLayout,
String[] groupFrom,
int[] groupTo,
List<? extends List<? extends Map<String, ?>>> childData,
int childLayout,
String[] childFrom,
int[] childTo)
构造函数
Parameters |
context |
Context : The context where the ExpandableListView associated with this SimpleExpandableListAdapter is running |
groupData |
List : A List of Maps. Each entry in the List corresponds to one group in the list. The Maps contain the data for each group, and should include all the entries specified in "groupFrom" |
groupLayout |
int : resource identifier of a view layout 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 keys that will be fetched from the Map associated with each group. |
groupTo |
int : The group views that should display column in the "groupFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the groupFrom parameter. |
childData |
List : A List of List of Maps. Each entry in the outer List corresponds to a group (index by group position), each entry in the inner List corresponds to a child within the group (index by child position), and the Map corresponds to the data for a child (index by values in the childFrom array). The Map contains the data for each child, and should include all the entries specified in "childFrom" |
childLayout |
int : resource identifier of a view layout 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 keys that will be fetched from the Map associated with each child. |
childTo |
int : The child views that should display column in the "childFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the childFrom parameter. |
SimpleExpandableListAdapter
SimpleExpandableListAdapter (Context context,
List<? extends Map<String, ?>> groupData,
int expandedGroupLayout,
int collapsedGroupLayout,
String[] groupFrom,
int[] groupTo,
List<? extends List<? extends Map<String, ?>>> childData,
int childLayout,
String[] childFrom,
int[] childTo)
构造函数
Parameters |
context |
Context : The context where the ExpandableListView associated with this SimpleExpandableListAdapter is running |
groupData |
List : A List of Maps. Each entry in the List corresponds to one group in the list. The Maps contain the data for each group, and should include all the entries specified in "groupFrom" |
expandedGroupLayout |
int : resource identifier of a view layout that defines the views for an expanded group. The layout file should include at least those named views defined in "groupTo" |
collapsedGroupLayout |
int : resource identifier of a view layout that defines the views for a collapsed group. The layout file should include at least those named views defined in "groupTo" |
groupFrom |
String : A list of keys that will be fetched from the Map associated with each group. |
groupTo |
int : The group views that should display column in the "groupFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the groupFrom parameter. |
childData |
List : A List of List of Maps. Each entry in the outer List corresponds to a group (index by group position), each entry in the inner List corresponds to a child within the group (index by child position), and the Map corresponds to the data for a child (index by values in the childFrom array). The Map contains the data for each child, and should include all the entries specified in "childFrom" |
childLayout |
int : resource identifier of a view layout 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 keys that will be fetched from the Map associated with each child. |
childTo |
int : The child views that should display column in the "childFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the childFrom parameter. |
SimpleExpandableListAdapter
SimpleExpandableListAdapter (Context context,
List<? extends Map<String, ?>> groupData,
int expandedGroupLayout,
int collapsedGroupLayout,
String[] groupFrom,
int[] groupTo,
List<? extends List<? extends Map<String, ?>>> childData,
int childLayout,
int lastChildLayout,
String[] childFrom,
int[] childTo)
构造函数
Parameters |
context |
Context : The context where the ExpandableListView associated with this SimpleExpandableListAdapter is running |
groupData |
List : A List of Maps. Each entry in the List corresponds to one group in the list. The Maps contain the data for each group, and should include all the entries specified in "groupFrom" |
expandedGroupLayout |
int : resource identifier of a view layout that defines the views for an expanded group. The layout file should include at least those named views defined in "groupTo" |
collapsedGroupLayout |
int : resource identifier of a view layout that defines the views for a collapsed group. The layout file should include at least those named views defined in "groupTo" |
groupFrom |
String : A list of keys that will be fetched from the Map associated with each group. |
groupTo |
int : The group views that should display column in the "groupFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the groupFrom parameter. |
childData |
List : A List of List of Maps. Each entry in the outer List corresponds to a group (index by group position), each entry in the inner List corresponds to a child within the group (index by child position), and the Map corresponds to the data for a child (index by values in the childFrom array). The Map contains the data for each child, and should include all the entries specified in "childFrom" |
childLayout |
int : resource identifier of a view layout that defines the views for a child (unless it is the last child within a group, in which case the lastChildLayout is used). The layout file should include at least those named views defined in "childTo" |
lastChildLayout |
int : resource identifier of a view layout that defines the views for the last child within each group. The layout file should include at least those named views defined in "childTo" |
childFrom |
String : A list of keys that will be fetched from the Map associated with each child. |
childTo |
int : The child views that should display column in the "childFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the childFrom parameter. |
Public methods
getChild
Object 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
|
getGroup
Object 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
|
newChildView
View newChildView (boolean isLastChild,
ViewGroup parent)
为一个孩子实例化一个新的View。
Parameters |
isLastChild |
boolean : Whether the child is the last child within its group. |
parent |
ViewGroup : The eventual parent of this new View. |
Returns |
View |
A new child View |
newGroupView
View newGroupView (boolean isExpanded,
ViewGroup parent)
实例化组的新视图。
Parameters |
isExpanded |
boolean : Whether the group is currently expanded. |
parent |
ViewGroup : The eventual parent of this new View. |
Returns |
View |
A new group View |