When i try to set the adapter to my ExpendableListView it expects ListAdapter but i want to use a custom ExpandableListAdapter which extends BaseExpandableListAdapter
This is my 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>
Setting the adapter:
exp_lv_nav.adapter = ExpandableListAdapter(this, listDataHeader, listDataChild, exp_lv_nav)
And this is what I get when building:
Error : Type mismatch: inferred type is ExpandableListAdapter but ListAdapter! was expected
Top of my adapter:
public class ExpandableListAdapter extends BaseExpandableListAdapter {
private Context mContext;
private List<ExpandedMenuModel> mListDataHeader;
private HashMap<ExpandedMenuModel, List<String>> mListDataChild;
ExpandableListView expandList;
public ExpandableListAdapter(Context context, List<ExpandedMenuModel> listDataHeader, HashMap<ExpandedMenuModel, List<String>> listChildData, ExpandableListView mView) {
this.mContext = context;
this.mListDataHeader = listDataHeader;
this.mListDataChild = listChildData;
this.expandList = mView;
}
It seems to be a problem in Kotlin. For now, instead of setting the adapter using Kotlin's generated getter/setter as you have in the question:
exp_lv_nav.adapter = ExpandableListAdapter(this, listDataHeader, listDataChild, exp_lv_nav)
replace with:
exp_lv_nav.setAdapter(ExpandableListAdapter(this, listDataHeader, listDataChild, exp_lv_nav))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With