![]() ![]() Your ListView has no hope of performing well if you are doing things like accessing the disk or a database on the main thread inside your adapter's getView. The short answer is that notifyDatasetChanged does everything invalidateViews does and more, and almost always does everything you are looking for. After that, the views are redrawn taking the new data into account. On the other hand, notifyDatasetChagned() tells the Observer watching your adapter to look for changes in the list's data. However, if you want to change the color of the text of your views without touching the data behind them, ListView.invalidateViews() may be all that you need. This means that if you added an item to the Adapter, it will not appear and if you removed an item, it will not disappear. ![]() The trick here is that invalidateViews can't observe changes to the Adapter's data and does nothing but redraw the views that are currently on screen. So you have made some changes to the data backing a ListView, how do you now get the ListView to draw those changes on screen? If you look at the Android documentation, the two obvious candidates are ListView.invalidateViews() and Adapter.notifyDatasetChanged(). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |