When we do Android list development, we sometimes encounter problems like this:
Java.lang.IllegalStateException:The content of the adapter have changed but ListView do not receive a notification. Make sure the content of your adapter are not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifydatasetchanged () while its content changes.
Basically, the content of your adapter changes, but your listview doesn't know it. Make sure your adapter data is changed in the main thread!
Check the Android source code to see where the exception is thrown out.
The Layoutchildren () method in the ListView has the following method:
Handle the empty set by removing all views that is visible
And calling it a day
if (Mitemcount = = 0) {
Resetlist ();
Invokeonitemscrolllistener ();
Return
} else if (mitemcount! = Madapter.getcount ()) {
throw new IllegalStateException ("The content of the adapter have changed but"
+ "ListView did not receive a notification. Make sure the content of "
+ "Your adapter is not modified from a background thread, and only"
+ "from the UI thread. [In ListView ("+ getId () +", "+ getclass ()
+ ") with Adapter (" + madapter.getclass () + ")]");
}
This means that the exception is thrown when the data count in the ListView cache is not equal to Adapter.getcount () in the ListView.
Knowing the reason, it's better to change it.
is when you do adapter within the item to increase, delete, be sure to synchronize the Notifydatasetchanged () method to notify the update. And also in the main thread.
So this problem is solved!
Android Development Tutorial--About adapter The content of the adapter has changed problem analysis