Reputation: 163
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.
my list-view contains huge data`s
am calling the bellow code using handler when the data is changed in the list
listviewAdapter.notifyDataSetChanged();
but i get the same error some times and not every time i load it thanks in advance
Upvotes: 2
Views: 2776
Reputation: 5177
the question is not where the adapter update, it should be: the time the adapter update.
it look likes: your data bind to the adapter has be changed, and the ui have be updated, so this time, the system find the data changed but can't invoke the notifyDataSetChanged
.
so, suggestion when you change the adapter's data, invoke notifyDataSetChanged
immediately,
or
dont directed change the adapter's data in your thread, you should send the data to the hanlder
, and in the handler
using the data to replace or change the adapter's data and notifyDataSetChanged
.
so anyway, suggestion get the data can run in background thread, and update the data , notifyDataSetChanged
used in ui thread.
Upvotes: 2
Reputation: 7634
Modify the arguments of the adapter in runOnUIThread() or use a handler to notify the adapter that the dataset has changed.
Upvotes: 0
Reputation: 157457
the error is quite clear. You have not to call listviewAdapter.notifyDataSetChanged();
from a thread different of the UI thread.
Upvotes: 0