Thanks all for responding. This has been most helpful! On Thu, Nov 19, 2009 at 8:49 PM, Romain Guy <romain...@google.com> wrote:
> ListView does everything on the UI thrad. > > > I am pretty sure the adapter in this app is not being modified outside of > > the UI thread but I can cause the exception to be thrown. > > Modifying the data structure(s) that backs the adapter on a background > thread could cause this. > > > > > Thanks, > > > > On Thu, Nov 19, 2009 at 2:24 PM, Dianne Hackborn <hack...@android.com> > > wrote: > >> > >> As the exception says: > >> > >> throw new 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. [in ListView(" + getId() > + > >> ", " + getClass() > >> + ") with Adapter(" + mAdapter.getClass() + > ")]"); > >> > >> You can't modify an adapter from a background thread; this must be done > on > >> the main thread. > >> > >> This exception is not adding a restriction; it is making it more obvious > >> when you do something that would always break in weird, subtle, and/or > >> horrible ways. > >> > >> On Thu, Nov 19, 2009 at 5:56 AM, WoodManEXP <woodman...@gmail.com> > wrote: > >>> > >>> For Google about BaseAdapter class > >>> > >>> In Android 1.6 and 2.0 the BaseAdapter class has apparently been > >>> modified to throw an exception when it sees the Adapter.getCount() > >>> method return a number different than what it picked up when > >>> BaseAdapter.notifyDataSetChanged() was called (at least I did not > >>> observe this behavior in pre 1.6). > >>> > >>> So now the question is, when should one call notifyDataSetChanged() or > >>> more importantly, when can the count in the Adapter be safely changed? > >>> > >>> Consider the case of an app with a background thread delivering data > >>> to a BaseAdapter at a rate faster than the ListView responds to > >>> notifyDataSetChanged(). Because notifyDataSetChanged() is a > >>> synchronous call and the ListView updates are taking place sometime in > >>> the indeterminate future on the UI thread, how can an app know when it > >>> is safe to change the adapter count? > >>> > >>> If the app changes the count while the ListView is updating itself the > >>> exception will be thrown (and there is no way to catch the exception). > >>> > >>> Is there a way to know when it is safe to change the count in the > >>> BaseAdapter? > >>> > >>> -- > >>> 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<android-developers%2bunsubscr...@googlegroups.com> > >>> For more options, visit this group at > >>> http://groups.google.com/group/android-developers?hl=en > >> > >> > >> > >> -- > >> Dianne Hackborn > >> Android framework engineer > >> hack...@android.com > >> > >> Note: please don't send private questions to me, as I don't have time to > >> provide private support, and so won't reply to such e-mails. All such > >> questions should be posted on public forums, where I and others can see > and > >> answer them. > >> > >> -- > >> 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<android-developers%2bunsubscr...@googlegroups.com> > >> For more options, visit this group at > >> http://groups.google.com/group/android-developers?hl=en > > > > -- > > 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<android-developers%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > > http://groups.google.com/group/android-developers?hl=en > > > > -- > Romain Guy > Android framework engineer > romain...@android.com > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them > > -- > 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<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- 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