我有工作ListView
我正在尝试在其中添加子项。但list.setAdapter(new SimpleAdapter(this, list, label, wala));
String[] resName = new String[(int) dataSnapshot.getChildrenCount()];
String[] resLoc;
ListView list = (ListView) findViewById(R.id.listViewRest);
restauList = new ArrayList<HashMap<String, String>>();
resLoc = new String[]{"TRY", "TRY2"};
int i = 0;
for (DataSnapshot dataSnapshot1 : dataSnapshot.getChildren()) {
resName[i] = dataSnapshot1.child("resname").getValue().toString();
HashMap<String, String> listahan = new HashMap<String, String>();
listahan.put("Restaurant Name", String.valueOf(resName));
listahan.put("Location", String.valueOf(resLoc));
restauList.add(listahan);
i++;
}
String [] label = new String[] {"Name", "Location"};
int [] wala = new int []{ android.R.id.text1, android.R.id.text2 };
int layout = android.R.layout.two_line_list_item;
list.setAdapter(new SimpleAdapter(this, list, label, wala));
答案 0 :(得分:0)
如果我没有错,你可以尝试使用expandable listview来浏览这个链接
答案 1 :(得分:0)
您应该使用ExpandableListView在listView中添加subItem。