我正在使用一个ExpandableListView
,ViewPager
所以onPageSelected()
我需要清除列表.
我知道有一种方法可以做到这ListView
一点setAdapter(null)
但是The method setAdapter(ListAdapter) is ambiguous for the type ExpandableListView
如果我尝试的话我会收到错误ExpandableListView
.
你试过输入一个空的适配器吗?类似于以下内容:
ExpandableListAdapter adapter = new ExpandableListAdapter(); //or what ever adapter you use/created listView.setAdapter(adapter);
这不是null适配器,您将不会获得空指针,并且适配器将不包含要显示/显示/填充的元素.
你可以adapter
通过调用来检查它是否为空isEmpty()
尝试使用BaseExpandableListAdapter类型转换null,如下所示.
listview.setAdapter((BaseExpandableListAdapter)null);