【问题标题】:clear ExpandableListView清除 ExpandableListView
【发布时间】:2014-02-02 13:26:12
【问题描述】:

我正在使用ExpandableListViewViewPager,所以在onPageSelected() 中我需要清除列表。

我知道ListView 的一种方法是setAdapter(null),但如果我在ExpandableListView 上尝试,我会收到The method setAdapter(ListAdapter) is ambiguous for the type ExpandableListView 错误。

【问题讨论】:

    标签: android expandablelistview expandablelistadapter


    【解决方案1】:

    尝试使用 BaseExpandableListAdapter 类型转换 null,如下所示。

    listview.setAdapter((BaseExpandableListAdapter)null);
    

    【讨论】:

      【解决方案2】:

      您是否尝试过输入一个空的适配器?类似于以下内容:

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

      这不是空适配器,您不会得到空指针。适配器将不包含要显示/显示/填充的元素。

      您可以通过调用isEmpty() 来检查adapter 是否为空。

      【讨论】:

        猜你喜欢
        • 2020-03-11
        • 1970-01-01
        • 1970-01-01
        • 2011-11-16
        • 2012-04-22
        • 2018-12-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多