What does the method adapter.notifyDataSetInvalidated() accomplish? There is no documentation on it.
I am trying to reload a ListView and notifyDataSetChanged or notifyDataSetInvalidated don't seem to accomplish anything.
What does the method adapter.notifyDataSetInvalidated() accomplish? There is no documentation on it.
I am trying to reload a ListView and notifyDataSetChanged or notifyDataSetInvalidated don't seem to accomplish anything.
It depends on the adapter implementation... if you take a look of the source code you will see that:
notifyDataSetInvalidated()
calls the notifyInvalidated()
of the DataSetObservable
class (see here)notifyInvalidated()
calls the onInvalidated()
method for each DataSetObserver
(see here).onInvalidated()
does not do anything...This is its implementation:
public void onInvalidated() {
// Do nothing
}
DataSetObserver
is an abstract class, so it's up to the subclass to decide what to do on onInvalidated()
.
afaik the notifyDataSetInvalidated()
stops the adapter from accessing the data in case its invalid or gone or something. notifyDataSetChanged()
updates the ListView so you can see the new data added but you have to call it in the UI thread.
It helped me a lot to watch http://www.youtube.com/watch?v=wDBM6wVEO70 there are 2 sections where they mention those methods and explain how to use them correctly. Maybe it helps you too :)