westmeadboy wrote: > I'm using a SimpleCursorAdapter with ListView. > > I just noticed that calling AbstractCursor.close() in a non-UI thread > will cause this exception: > > android.view.ViewRoot$CalledFromWrongThreadException: Only the > original thread that created a view hierarchy can touch its views. > at android.view.ViewRoot.checkThread(ViewRoot.java:2462) > at android.view.ViewRoot.requestLayout(ViewRoot.java:512) > at android.view.View.requestLayout(View.java:7071) > at android.view.View.requestLayout(View.java:7071) > at android.view.View.requestLayout(View.java:7071) > at android.view.View.requestLayout(View.java:7071) > at android.view.View.requestLayout(View.java:7071) > at android.widget.AbsListView.requestLayout(AbsListView.java:969) > at android.widget.AdapterView > $AdapterDataSetObserver.onInvalidated(AdapterView.java:811) > at > android.database.DataSetObservable.notifyInvalidated(DataSetObservable.java: > 43) > at > android.widget.BaseAdapter.notifyDataSetInvalidated(BaseAdapter.java: > 54) > at android.widget.CursorAdapter > $MyDataSetObserver.onInvalidated(CursorAdapter.java:391) > at > android.database.DataSetObservable.notifyInvalidated(DataSetObservable.java: > 43) > at > android.database.AbstractCursor.deactivateInternal(AbstractCursor.java: > 89) > at android.database.AbstractCursor.close(AbstractCursor.java:108) > > Is this a bug or intentional?
This is intentional. The Cursor is tied to the UI thread once you put it in a CursorAdapter and attach that CursorAdapter to an AdapterView (e.g., ListView). -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Training in NYC: 4-6 June 2010: http://guruloft.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.

