SimpleExpandableListAdapter:
public class LocalAdapter extends SimpleExpandableListAdapter {
private List<? extends Map<String, ?>> mGroupData;
private String[] mGroupFrom;
private int[] mGroupTo;
private List<? extends List<? extends Map<String, ?>>> mChildData;
private LayoutInflater mInflater;
public LocalAdapter(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) {
this(context, groupData, groupLayout, groupLayout, groupFrom, groupTo, childData,
childLayout, childLayout, childFrom, childTo);
}
public LocalAdapter(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) {
this(context, groupData, expandedGroupLayout, collapsedGroupLayout,
groupFrom, groupTo, childData, childLayout, childLayout,
childFrom, childTo);
}
public LocalAdapter(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) {
super(context, groupData, expandedGroupLayout,
collapsedGroupLayout, groupFrom, groupTo, childData,
childLayout, lastChildLayout, childFrom, childTo);
mGroupData = groupData;
mGroupFrom = groupFrom;
mGroupTo = groupTo;
mChildData = childData;
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
private void bindView(View view, Map<String, ?> data, 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]));
}
}
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
ViewGroup parent) {
View v = newGroupView(isExpanded, parent);
bindView(v, mGroupData.get(groupPosition), mGroupFrom, mGroupTo);
return v;
}
}