How to refresh an Android ListView
after adding/deleting dynamic data?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
if you are not still satisfied with ListView Refreshment, you can look at this snippet,this is for loading the listView from DB, Actually what you have to do is simply reload the ListView,after you perform any CRUD Operation Its not a best way to code, but it will refresh the ListView as you wish..
It works for Me....if u find better solution,please Share...
on other option is
onWindowFocusChanged
method, but sure its sensitive and needs some extra coding for whom is interestedI was only able to get notifyDataSetChanged only by getting new adapter data, then resetting the adapter for the list view, then making the call like so:
You need to use a single object of that list whoose data you are inflating on
ListView
. If reference is change thennotifyDataSetChanged()
does't work .Whenever You are deleting elements from list view also delete them from the list you are using whether it is a ArrayList<> or Something else then CallnotifyDataSetChanged()
on object of Your adapter class.So here see how i managed it in my adapter see below
while using SimpleCursorAdapter can call changeCursor(newCursor) on the adapter.
Call
notifyDataSetChanged()
on yourAdapter
object once you've modified the data in that adapter.Some additional specifics on how/when to call
notifyDataSetChanged()
can be viewed in this Google I/O video.