SimpleExpandableListAdapterpublic class SimpleExpandableListAdapter extends BaseExpandableListAdapter An easy adapter to map static data to group and child views defined in an XML
file. You can separately specify the data backing the group as a List of
Maps. Each entry in the ArrayList corresponds to one group in the expandable
list. The Maps contain the data for each row. You also specify an XML file
that defines the views used to display a group, and a mapping from keys in
the Map to specific views. This process is similar for a child, except it is
one-level deeper so the data backing is specified as a List>,
where the first List corresponds to the group of the child, the second List
corresponds to the position of the child within the group, and finally the
Map holds the data for that particular child. |
Fields Summary |
---|
private List | mGroupData | private int | mExpandedGroupLayout | private int | mCollapsedGroupLayout | private String[] | mGroupFrom | private int[] | mGroupTo | private List | mChildData | private int | mChildLayout | private int | mLastChildLayout | private String[] | mChildFrom | private int[] | mChildTo | private android.view.LayoutInflater | mInflater |
Constructors Summary |
---|
public SimpleExpandableListAdapter(android.content.Context context, List groupData, int groupLayout, String[] groupFrom, int[] groupTo, List childData, int childLayout, String[] childFrom, int[] childTo)Constructor
this(context, groupData, groupLayout, groupLayout, groupFrom, groupTo, childData,
childLayout, childLayout, childFrom, childTo);
| public SimpleExpandableListAdapter(android.content.Context context, List groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List childData, int childLayout, String[] childFrom, int[] childTo)Constructor
this(context, groupData, expandedGroupLayout, collapsedGroupLayout,
groupFrom, groupTo, childData, childLayout, childLayout,
childFrom, childTo);
| public SimpleExpandableListAdapter(android.content.Context context, List groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List childData, int childLayout, int lastChildLayout, String[] childFrom, int[] childTo)Constructor
mGroupData = groupData;
mExpandedGroupLayout = expandedGroupLayout;
mCollapsedGroupLayout = collapsedGroupLayout;
mGroupFrom = groupFrom;
mGroupTo = groupTo;
mChildData = childData;
mChildLayout = childLayout;
mLastChildLayout = lastChildLayout;
mChildFrom = childFrom;
mChildTo = childTo;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
Methods Summary |
---|
private void | bindView(android.view.View view, java.util.Map data, java.lang.String[] from, int[] to)
int len = to.length;
for (int i = 0; i < len; i++) {
TextView v = (TextView)view.findViewById(to[i]);
if (v != null) {
v.setText((String)data.get(from[i]));
}
}
| public java.lang.Object | getChild(int groupPosition, int childPosition)
return mChildData.get(groupPosition).get(childPosition);
| public long | getChildId(int groupPosition, int childPosition)
return childPosition;
| public android.view.View | getChildView(int groupPosition, int childPosition, boolean isLastChild, android.view.View convertView, android.view.ViewGroup parent)
View v;
if (convertView == null) {
v = newChildView(isLastChild, parent);
} else {
v = convertView;
}
bindView(v, mChildData.get(groupPosition).get(childPosition), mChildFrom, mChildTo);
return v;
| public int | getChildrenCount(int groupPosition)
return mChildData.get(groupPosition).size();
| public java.lang.Object | getGroup(int groupPosition)
return mGroupData.get(groupPosition);
| public int | getGroupCount()
return mGroupData.size();
| public long | getGroupId(int groupPosition)
return groupPosition;
| public android.view.View | getGroupView(int groupPosition, boolean isExpanded, android.view.View convertView, android.view.ViewGroup parent)
View v;
if (convertView == null) {
v = newGroupView(isExpanded, parent);
} else {
v = convertView;
}
bindView(v, mGroupData.get(groupPosition), mGroupFrom, mGroupTo);
return v;
| public boolean | hasStableIds()
return true;
| public boolean | isChildSelectable(int groupPosition, int childPosition)
return true;
| public android.view.View | newChildView(boolean isLastChild, android.view.ViewGroup parent)Instantiates a new View for a child.
return mInflater.inflate((isLastChild) ? mLastChildLayout : mChildLayout, parent, false);
| public android.view.View | newGroupView(boolean isExpanded, android.view.ViewGroup parent)Instantiates a new View for a group.
return mInflater.inflate((isExpanded) ? mExpandedGroupLayout : mCollapsedGroupLayout,
parent, false);
|
|