【发布时间】:2016-11-23 19:35:02
【问题描述】:
我收到发送到我的ExpandableListViewAdapter 列表。里面有String title 和另一个列表。
我正在关注本指南http://www.androhub.com/android-expandablelistview/,但不知道如何接收(在适配器构造函数上)我的列表以显示 ExpandableListView
我试过了:
private List<MyClass> dat;
private Context _context;
private List<String> header, a;
private HashMap<String, List<String>> child;
public TestAdapter(Context _context, List<MyClass> dat) {
this._context = _context;
this.dat = dat;
HashMap<String, List<String>> hashMap = new HashMap<String, List<String>>();
for(int i = 0; i<dat.size(); i++){
for(int j = 0; j < dat.get(i).getDestinations().size(); j++){
a.add(dat.get(i).getDestinations().get(j).getTitle());
}
header.add(dat.get(i).getTitle());
}
for(int i = 0; i<header.size(); i++){
hashMap.put(header.get(i), a);
}
}
但不起作用。
【问题讨论】:
-
您必须为您的标题项目和您的子项目列表创建一个数据类型的哈希图
标签: android adapter expandablelistview