2 回答
TA贡献1807条经验 获得超9个赞
用于创建数据列表。假设Column1为Heading,Column2为SubHeading,请在活动/片段中尝试以下操作:
ArrayList<String> headings = new ArrayList<>();
HashMap<String, ArrayList<String>> subheadings = new HashMap<>();
String heading, subheading;
do{
heading = cursor.getString(1);
subheading = cursor.getString(2);
ArrayList<String> tmpChild;
if(headings.contains(heading)){
tmpChild = subheadings.get(heading);
}else{
headings.add(heading);
tmpChild = new ArrayList<>();
}
tmpChild.add(subheading);
subheadings.put(heading, tmpChild);
}while (cursor.moveToNext());
对于适配器,请在此处尝试我的答案:带有复选框的树
添加回答
举报