Refresh an listView after insert on database

a 夏天 提交于 2019-12-08 05:14:06

问题


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..


回答1:


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.


来源:https://stackoverflow.com/questions/5650086/refresh-an-listview-after-insert-on-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!