【发布时间】:2017-06-19 07:17:26
【问题描述】:
我正在尝试使用 Kotlin 在 Android Studio 中动态填充我的可扩展列表视图。但截至目前,我无法找到任何最新的功能来做到这一点,我发现的所有功能似乎都已经过时了。这是我的骨架代码:
private val shows = listOf("First", "Breaking Bad", "Game of Thrones", "Bob and Martin...")
private val expandableListView: ExpandableListView by bind(R.id.theListView)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//Add items to expandable list view here
}
提前致谢
【问题讨论】:
-
谷歌“ExpandableListView 示例”,您应该能够弄清楚。
-
是的,我找到了 setAdapter 函数。似乎只是在努力创建 ExpandableListAdapter。我只设法让 ArrayAdapter 工作,这对我没有多大帮助。