As many others, I am getting IllegalStateException when using a ListView :(
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
I know the basic explanation - I am probably trying to modify the list from background thread. After exploring my code over and over again, I cant find a place that I am actually doing that. I am not adding \ removing elements from the list - it is static, and does not change from creation. What I AM doing is only modifying the internal data of the list's elements from a worker thread - but I am not sure if it is actually my problem. so - this is my question - is it allowed to modify the underneath data of the list elements from background thread as long as I do not modify the list itself by adding \ removing elements?
Update: Well I guess you are right, so here is a pseudo code:
//from main GUI thread.
ArrayList<People> namesList = // create and populate the list...
//lets assume that NamesArrayAdapter extends ArrayAdapter<People>
NamesArrayAdapter adapter = new NamesArrayAdapter(context, listViewResource, namesList); //instantiate the list adapter
//from backgroung thread
namesList.getItem(0).setName("et"); //Modifying existing element inside the list - is this ligal???
I AM doing is only modifying the internal data of the list's elements from a worker thread
Is it the same static list as you set in Adapter
?
Then you can not change them from Background Thread
. If you change them then make sure you call notifyDataSetChanged
.