Frage

I am using an ExpandableListView along with a ViewPager so in onPageSelected() I need to clear the list.

I know one way to do it for a ListView is setAdapter(null) but I get The method setAdapter(ListAdapter) is ambiguous for the type ExpandableListView error if I try it on ExpandableListView.

War es hilfreich?

Lösung 2

Have you tried inputting an empty adapter? Something like the following:

ExpandableListAdapter adapter = new ExpandableListAdapter(); //or what ever adapter you use/created
listView.setAdapter(adapter);

This is not a null adapter and you will not get a null pointer. The adapter will contain no elements to display/show/populate.

You can check if the adapter is empty by calling isEmpty().

Andere Tipps

Try by type casting null with BaseExpandableListAdapter like below.

listview.setAdapter((BaseExpandableListAdapter)null);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top