用于ExpandableListView的android notifyDataSetChanged不起作用

Jyo*_*sna 6 android expandablelistview

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

ExpandableListView的项目包含与数据库链接的删除按钮.如果我按下删除按钮,该项将从db中永久删除.但listview同时并不令人耳目一新.如果我再次运行该活动,那么它是令人耳目一新的但不是同时.我在用

mAdapter.notifyDataSetChanged();
Run Code Online (Sandbox Code Playgroud)

但它没有按我的意愿工作.为什么?

Cat*_*ata 8

我刚刚调用了BaseExpandableListAdapter的以下重写方法,从那时起notifyDataSetChanged()工作.

    @Override
    public void registerDataSetObserver(DataSetObserver observer) {
        super.registerDataSetObserver(observer);    
    }
Run Code Online (Sandbox Code Playgroud)


sen*_*ola 4

您可以尝试在刷新时在 ExpandableListView 上另外调用 invalidateViews() 。