gpt4 book ai didi

android - 如何从对象列表在 android 中创建可扩展 ListView ?

转载 作者:太空狗 更新时间:2023-10-29 16:17:46 27 4
gpt4 key购买 nike

我在 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com