用于ExpandableListView的android notifyDataSetChanged无法正常工作 [英] android notifyDataSetChanged for ExpandableListView not working

查看:101
本文介绍了用于ExpandableListView的android notifyDataSetChanged无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my app I am working with ExpandableListView. I am using adapter which extends BaseExpandableListAdapter. I want to refresh the ExpandableListView.

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

My ExpandableListView consists of items with delete button which links with database. If I'll press the delete button that item is permanently deleted from db. But the listview is not refreshing at the same time. If I again run that activity its refreshing but not at same time. I am using

mAdapter.notifyDataSetChanged();

但是它不能按我的要求工作. 为什么?

but its not working as I want. Why?

推荐答案

我只是在BaseExpandableListAdapter的以下重写方法上调用了super,从那时起notifyDataSetChanged()就可以工作了.

I just called super on the following overridden method of the BaseExpandableListAdapter and since then the notifyDataSetChanged() works.

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

这篇关于用于ExpandableListView的android notifyDataSetChanged无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆