ExpandableListView 的 android notifyDataSetChanged 不工作

标签 android expandablelistview

在我的应用程序中,我正在使用 ExpandableListView。我正在使用扩展 BaseExpandableListAdapter 的适配器。我想刷新 ExpandableListView

我的 ExpandableListView 由带有与数据库链接的删除按钮的项目组成。 如果我按下删除按钮,该项目将从数据库中永久删除。但是 listview 并没有同时刷新。如果我再次运行该 Activity ,它会刷新但不会同时运行。 我正在使用

mAdapter.notifyDataSetChanged();

但它并没有像我想要的那样工作。 为什么?

最佳答案

我刚刚在 BaseExpandableListAdapter 的以下重写方法上调用了 super,从那时起 notifyDataSetChanged() 开始工作。

    @Override
    public void registerDataSetObserver(DataSetObserver observer) {
        super.registerDataSetObserver(observer);    
    }

关于ExpandableListView 的 android notifyDataSetChanged 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7817916/

相关文章:

java - Context 中的 getDrawable (int) 无法应用于 (java.lang.String)

android - 从 Android 上的适配器中刷新 ExpandableListView

android - 为什么 getGroupView 没有调用 ExpandableListView?

android - 如何从可扩展 ListView 中获取更新值

android - 如果在底部,ExpandableListView 不会滚动

android - 行无法使用代码动态添加到 Android 中的表格布局

javascript - onPause() 之后,地理位置在 WebView 上保持 Activity 状态

android - 在安卓中使用sdl

安卓 : How iterate through views of a expandableList

android - 将 Android 与网站数据库同步?