在数据库插入后刷新listView [英] Refresh an listView after insert on database

查看:242
本文介绍了在数据库插入后刷新listView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据库中插入或删除后刷新listView ..我搜索并发现notifyDataSetChanged(),但我不知道如何使用它..


$ b $有人可以解释一下如何做到这一点?甚至以不同的方式..

解决方案

当点击删除按钮时,请执行以下操作:


  1. 从数据库中删除相应的列表项。

  2. 通过执行再次填充列表的查询为您的列表获取一个新的游标。

  3. 使用 changeCurosr()

  4. 调用 notifyDataSetChanged()


I want to refresh the listView after an insert or delete in the database.. I search and i found notifyDataSetChanged () but i don't know how to use it..

Someone can explain how to do this? Even by a different way..

解决方案

When the delete button is clicked do the following:

  1. Delete the corresponding list item from the database.
  2. Get an new cursor for your list by executing the query which fills the list again.
  3. Bind the new cursor to the list using changeCurosr().
  4. Call notifyDataSetChanged() on the adapter.

这篇关于在数据库插入后刷新listView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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