I'm getting an unhandled exception in my class that fills an
arrayadapter from items in a database:

10-11 04:05:26.883: ERROR/AndroidRuntime(886):
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.

At the end of my OnCreate method I fire off a background thread:

                Thread thread = new Thread(null, doSearchDatabase,
"Background");
                thread.start();



I fill the array list in the run method of the thread, and use a
handler to post a message
at the end of the processing:

                hh.post(postdoSearchDatabase);

In the run method of the handler, which I presume is a UIThread, I do:

                Collections.sort(myArrayList);
                aa.notifyDataSetChanged();

Here I do let the array adapter know things have changed.

Does this exception always mean I'm doing something wrong with the
array adapter in a background
thread? I don't seem to be manipulating it at all in the background
thread; only the array list it is
connected to.

Any ideas? the exception isn't thrown every time, and if I step slowly
through in the debugger it is not
thrown. Seems FAR worse running in Android 1.6.

thanks,

pawpaw17
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to