我使用的是ExpandableListView和ViewPager,所以在onPageSelected()中,我需要清除列表。
对于ListView,我知道一种方法是setAdapter(null),但是如果在ExpandableListView上尝试,就会得到The method setAdapter(ListAdapter) is ambiguous for the type ExpandableListView错误。
发布于 2014-01-14 13:19:33
你试过输入一个空适配器吗?如下所示:
ExpandableListAdapter adapter = new ExpandableListAdapter(); //or what ever adapter you use/created
listView.setAdapter(adapter);这不是空适配器,也不会得到空指针。适配器将不包含要显示/显示/填充的元素。
您可以通过调用adapter来检查isEmpty()是否为空。
发布于 2015-05-18 10:57:58
尝试按类型使用BaseExpandableListAdapter进行空转换,如下所示。
listview.setAdapter((BaseExpandableListAdapter)null);https://stackoverflow.com/questions/21114346
复制相似问题