我在 android 中有一个对象列表。我想遍历列表并创建一个可扩展的 ListView ,每个对象一个条目。我已经在 xml 文件中创建了 ExpandableListView
。所以我知道我开始于:
ExpandableListView results = ((ExpandableListView)rootView.findViewById(R.id.results));
我想遍历对象列表并为每个对象创建一个Parent
,每个Child
将是主对象的一个实例变量。
例如:
Parent = Object.Title
Child1 = Object.Taste
Child2 = Object.smell
Parent1 = Object1.Title
Child1 = Object1.Taste
Child2 = Object1.smell
最佳答案
您需要创建扩展 BaseExpandableListAdapter
的适配器,它将管理 subview 和父 View 。见this了解详情。
关于android - 如何从对象列表在 android 中创建可扩展 ListView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22626609/