【发布时间】:2021-10-29 17:05:47
【问题描述】:
我用静态值创建了 Kotlin 代码:
我想知道如何使用 jetpack compose 创建相同的内容?我不知道
代码:
class TestApp : AppCompatActivity() {
var listAdapter: ExpandableListAdapter? = null
var expListView: ExpandableListView? = null
var listDataHeader: MutableList<String>? = null
var listDataChild: HashMap<String, List<String>>? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
expListView = findViewById<View>(R.id.lvExp) as ExpandableListView
prepareListData()
listAdapter = ExpandableListAdapter(this, listDataHeader, listDataChild)
expListView!!.setAdapter(listAdapter)
}
private fun prepareListData() {
listDataHeader = ArrayList()
listDataChild = HashMap()
listDataHeader?.add(getString(R.string.q_1))
val on_0: MutableList<String> = ArrayList()
on_0.add(getString(R.string.faq_d_0))
listDataChild!![listDataHeader!![0]] = on_0
}
}
【问题讨论】:
-
即使我想要相同的解决方案,使用回收站视图进行改造!
标签: android expandablelistview android-jetpack-compose