当我尝试将适配器设置为我的 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) android expandablelistview listadapter android-listview kotlin
片段内的 getActivity (kotlin: activity) 给了我 FragmentActivity。但是现在我需要 Activity 而不是 FragmentActivity 用于特定的侦听器,并且无法将其转换为 Activity。
android android-fragments android-activity android-fragmentactivity