小编Kin*_*ufo的帖子

将适配器设置为 ExpendableListView 类型不匹配

当我尝试将适配器设置为我的 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

7
推荐指数
1
解决办法
399
查看次数

我如何获得 Activity 而不是 FragmentActivty?

片段内的 getActivity (kotlin: activity) 给了我 FragmentActivity。但是现在我需要 Activity 而不是 FragmentActivity 用于特定的侦听器,并且无法将其转换为 Activity。

android android-fragments android-activity android-fragmentactivity

2
推荐指数
1
解决办法
4121
查看次数