gpt4 book ai didi

android - Android光标中的 "invalid statement in fillWindow()"是什么意思?

转载 作者:IT老高 更新时间:2023-10-28 21:48:24 24 4
gpt4 key购买 nike

我有时会在 logcat 输出中看到此错误,

Cursor: invalid statement in fillWindow().

当我按下返回键,然后在进入我的自定义 listview 之前进入默认的 Android listview 时,有时会发生这种情况。

这是什么意思?我该如何解决?因为它没有指向问题所在的任何代码行。

最佳答案

在处理 ListActivities 时,此问题与 Activity 停止时没有正确关闭 Cursor 对象、CursorAdapter 对象和 Database 对象有关,并且在 Activity 启动或恢复时没有正确设置。

我必须确保在 TabActivity 恢复时调用的 Activity 的 onStop 方法中按相应顺序关闭了 SimpleListAdapter、Cursors 和 Database 对象。

我已经关闭了 Cursor 和 Database 对象,但还没有关闭我的 SimpleListAdapter 光标。

/**
* onStop method
*
* Perform actions when the Activity is hidden from view
*
* @return void
*
*/
@Override
protected void onStop() {
try {
super.onStop();

if (this.mySimpleListAdapterObj !=null){
this.mySimpleListAdapterObj.getCursor().close();
this.mySimpleListAdapterObj= null;
}

if (this.mActivityListCursorObj != null) {
this.mActivityListCursorObj.close();
}

if (this.myDatabaseClassObj != null) {
this.myDatabaseClassObj.close();
}
} catch (Exception error) {
/** Error Handler Code **/
}// end try/catch (Exception error)
}// end onStop

关于android - Android光标中的 "invalid statement in fillWindow()"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4195089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com