问题
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
回答1:
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.
回答2:
the error is quite clear. You have not to call listviewAdapter.notifyDataSetChanged(); from a thread different of the UI thread.
回答3:
Modify the arguments of the adapter in runOnUIThread() or use a handler to notify the adapter that the dataset has changed.
来源:https://stackoverflow.com/questions/10241765/list-view-java-lang-illegalstateexception-even-after-calling-notifydatasetcanged