清除ExpandableListView

 小角落哭泣的身影 发布于 2023-02-02 23:38

我正在使用一个ExpandableListView,ViewPager所以onPageSelected()我需要清除列表.

我知道有一种方法可以做到这ListView一点setAdapter(null)但是The method setAdapter(ListAdapter) is ambiguous for the type ExpandableListView如果我尝试的话我会收到错误ExpandableListView.

2 个回答
  • 你试过输入一个空的适配器吗?类似于以下内容:

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

    这不是null适配器,您将不会获得空指针,并且适配器将不包含要显示/显示/填充的元素.

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

    2023-02-02 23:49 回答
  • 尝试使用BaseExpandableListAdapter类型转换null,如下所示.

    listview.setAdapter((BaseExpandableListAdapter)null);
    

    2023-02-02 23:52 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有