I've implemented a custom ListView and Adapter, and sometimes I receive IllegalStateException exception:” ERROR/AndroidRuntime(3575): 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.”
Here is some code example: public interface BuddyChangeListener { void onChange(List<Buddy> buddys); } public class BuddyListView extends ListView implements BuddyChangeListener public void onChange(List<Buddy> Buddy) { MyActivity.instance.handler.post(new Runnable() { public void run() { if (((BuddyAdapter) refreshListView.getAdapter()) ! = null) { ((BuddyAdapter) refreshListView.getAdapter()).update(Buddy); } } }); } public class BuddyAdapter extends BaseAdapter { private List<Buddy> buddyList; public BuddyAdapter (Context context, List<Buddy> buddyList) { this.buddyList= buddyList; } public void update(List<Buddy> buddyList) { this.buddyList= buddyList; this.notifyDataSetChanged(); } } Every time when the content of the list need to be updated I run from onChange method and I use a handler to change the adapter content,to update the content from UI thread. Can someone to tell me if I have made something wrong on update ? Thanks. -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.