数据库插入后刷新的ListView数据库、ListView

2023-09-08 08:38:14 作者:心之所向

我要刷新列表视图插入后,或在数据库中删除。我寻找,我发现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:

从数据库中删除相应的列表项。通过执行再次写满列表中查询获取你的列表中的新指针。 绑定使用新的光标到目录changeCurosr().呼叫notifyDataSetChanged()在适配器上。 Delete the corresponding list item from the database. Get an new cursor for your list by executing the query which fills the list again. Bind the new cursor to the list using changeCurosr(). Call notifyDataSetChanged() on the adapter.