I think this is fairly straightforward -- when using SimpleExpandableListAdapter, groups are populated via a List of Maps, and children are populated by a List of Lists o开发者_Go百科f Maps. When you construct the adapter, you tell it the key to access the Maps with, like so:
new SimpleExpandableListAdapter(
this,
createGroupList(), // returns List<Map>
R.layout.category_row,
new String[] { "Group Item" },
new int[] { R.id.row_name },
createChildList(), // returns List<List<Map>>
R.layout.feed_row,
new String[] { "Sub Item" },
new int[] { R.id.row_name }
);
My question is, say for a child, can I store extra data in this map and access it later? Say, could I put an additional key in the Map for a child, such as "Type"->"Premade" and access it later via the getChild() method of SimpleExpandableListAdapter?
I think you can. Just extend SimpleExpandableListAdapter and override getView().
精彩评论