Refresh an listView after insert on database

2019-06-05 15:25发布

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条回答
萌系小妹纸
2楼-- · 2019-06-05 15:58

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.
查看更多
登录 后发表回答