我正在使用 LoaderManager 从我的手机加载联系人列表的光标。
我实际上只使用这里给出的示例代码:
http://developer.android.com/reference/android/app/LoaderManager.html
我唯一的改变是,我没有将其用作主屏幕列表视图的适配器,而是将其用作 AutoCompleteTextView 的适配器。我的问题是,当我快速更改文本时,无论是通过疯狂输入,还是按住删除按钮来删除一行中的所有内容,都会导致此错误:
01-09 02:36:47.248: E/AndroidRuntime(24231): FATAL EXCEPTION: main
01-09 02:36:47.248: E/AndroidRuntime(24231): android.database.StaleDataException: Attempted to access a cursor after it has been closed.
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.database.BulkCursorToCursorAdaptor.throwIfCursorIsClosed(BulkCursorToCursorAdaptor.java:64)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.database.BulkCursorToCursorAdaptor.getColumnNames(BulkCursorToCursorAdaptor.java:159)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.database.AbstractCursor.getColumnIndex(AbstractCursor.java:283)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:308)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:78)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.widget.CursorAdapter.swapCursor(CursorAdapter.java:338)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.widget.CursorAdapter.changeCursor(CursorAdapter.java:309)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.widget.CursorFilter.publishResults(CursorFilter.java:67)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.os.Looper.loop(Looper.java:137)
01-09 02:36:47.248: E/AndroidRuntime(24231): at android.app.ActivityThread.main(ActivityThread.java:5070)
01-09 02:36:47.248: E/AndroidRuntime(24231): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 02:36:47.248: E/AndroidRuntime(24231): at java.lang.reflect.Method.invoke(Method.java:511)
01-09 02:36:47.248: E/AndroidRuntime(24231): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
01-09 02:36:47.248: E/AndroidRuntime(24231): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
01-09 02:36:47.248: E/AndroidRuntime(24231): at dalvik.system.NativeStart.main(Native Method)