【问题标题】:How to clear the ExpandableListView?如何清除 ExpandableListView?
【发布时间】:2020-03-11 13:01:21
【问题描述】:

我使用可扩展列表视图作为树视图结构,它需要不断更新,但由于我无法清除当前的可扩展列表视图,它会显示以前的数据和新数据。就像我最小化并再次打开应用程序一样,列表视图中有重复的数据。

【问题讨论】:

  • 在您的更新触发事件上,在您的适配器上调用 notifyDataSetChanged()。
  • 你能告诉我更新触发事件吗?
  • 你能分享代码吗?我需要看看你是如何为可扩展列表视图设置数据的。

标签: android expandablelistview expandablelistadapter


【解决方案1】:
yourExpandableListView.setAdapter((BaseExpandableListAdapter)null);

【讨论】:

    【解决方案2】:

    ExpandableListAdapter 适配器 = new ExpandableListAdapter(); //或您使用/创建的任何适配器 listView.setAdapter(adapter) 请试试这个

    【讨论】:

    • 我相信我们可以用它设置一个适配器,我也做了同样的事情,但是如果再次调用形成列表的方法,我想清除当前列表。
    • 在适配器设置之前清除在您的适配器中设置的数组列表并进行空检查
    • 你能写一个简短的语法你想表达什么吗?
    猜你喜欢
    • 2014-02-02
    • 2012-04-22
    • 1970-01-01
    • 1970-01-01
    • 2011-12-24
    • 2011-01-16
    • 2010-11-07
    • 2011-08-16
    • 2013-03-25
    相关资源
    最近更新 更多