Kin*_*ufo 7 android expandablelistview listadapter android-listview kotlin
当我尝试将适配器设置为我的 ExpendableListView 时,它需要 ListAdapter 但我想使用扩展 BaseExpandableListAdapter 的自定义 ExpandableListAdapter
这是我的 ExpandableListView:
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:layout_marginTop="160dp"
android:id="@+id/exp_lv_nav">
</ExpandableListView>
Run Code Online (Sandbox Code Playgroud)
设置适配器:
exp_lv_nav.adapter = ExpandableListAdapter(this, listDataHeader, listDataChild, exp_lv_nav)
Run Code Online (Sandbox Code Playgroud)
这就是我在构建时得到的:
Error : Type mismatch: inferred type is ExpandableListAdapter but ListAdapter! was expected
Run Code Online (Sandbox Code Playgroud)
我的适配器顶部:
Error : Type mismatch: inferred type is ExpandableListAdapter but ListAdapter! was expected
Run Code Online (Sandbox Code Playgroud)
这似乎是 Kotlin 中的一个问题。现在,不要像问题中那样使用 Kotlin 生成的 getter/setter 设置适配器:
exp_lv_nav.adapter = ExpandableListAdapter(this, listDataHeader, listDataChild, exp_lv_nav)
Run Code Online (Sandbox Code Playgroud)
用。。。来代替:
exp_lv_nav.setAdapter(ExpandableListAdapter(this, listDataHeader, listDataChild, exp_lv_nav))
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
399 次 |
最近记录: |