SimpleCursor适配器,LoaderManager IllegalState异常或StaleData异常

时间:2013-05-15 04:43:17

标签: android

我在SimpleCursor适配器和Loader Manager(支持v4)的帮助下填充了gridview。在分页的帮助下从web服务器获取gridview的内容。如果我在webservice调用期间快速切换详细视图和gridview之间的视图我得到非法状态错误/ StaleDataException。

05-15 00:36:54.114: E/AndroidRuntime(10656): java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteQuery: SELECT * FROM product_list WHERE (url =  ? )
05-15 00:36:54.114: E/AndroidRuntime(10656):    at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
05-15 00:36:54.114: E/AndroidRuntime(10656):    at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:58)
05-15 00:36:54.114: E/AndroidRuntime(10656):    at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:151)
05-15 00:36:54.114: E/AndroidRuntime(10656):    at android.database.sqlite.SQLiteCursor.onMove(SQLiteCursor.java:124)
05-15 00:36:54.114: E/AndroidRuntime(10656):    at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:213)
05-15 00:36:54.114: E/AndroidRuntime(10656):    at android.database.CursorWrapper.moveToPosition(CursorWrapper.java:162)
05-15 00:36:54.114: E/AndroidRuntime(10656):    at android.support.v4.widget.CursorAdapter.getView(CursorAdapter.java:247)
05-15 00:36:54.114: E/AndroidRuntime(10656):    at android.widget.AbsListView.obtainView(AbsListView.java:2452)
05-15 00:36:54.114: E/AndroidRuntime(10656):    at android.widget.GridView.makeAndAddView(GridView.java:1331

1 个答案:

答案 0 :(得分:0)

也许您忘了在resetLoader回调中添加adapter.swapcursor(null)? 我遇到了相同的日志,而这个日志已经丢失,并且多次打开+关闭了listfragment ..