开发者

Use of SimpleExpandableListAdapter

开发者 https://www.devze.com 2023-04-06 16:42 出处:网络
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

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().

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号