我有一个创建ListActivity的布局。在显示ListActivity之前,我执行一个数据库查询,然后使用SimpleCursorAdapter将该数据绑定到列表。StackOverflowError 1.5 vs 1.6
所有这些在1.6和更高版本上正常工作。在1.5上,执行查询的函数成功执行,但几秒钟后发生了StackOverflowError。有谁知道为什么这个错误会发生在1.5而不是在1.6?
更新:我确定当我从具有TabView的活动移动到具有ListView的活动时发生崩溃。如果我从不包含选项卡视图的活动转到ListView,则不会发生崩溃。带有ListView的活动将一个Cursor返回到数据库大约有10列的查询。在这10列中,我在屏幕上显示3列。
这里是执行我的代码流:
TabView Activity sends Intent to start List View Activity
onCreate() //of ListActivity
{
showList();
}
showList()
{
//open DataBase
//perform query
//create SimpleCursorAdapter
//setListAdapter
}
因此,举例来说,这完全运行罚款一Droid的安装2.1和仿真器瞄准1.6。但是,上述失败的HTC Hero 1.5和1.5的仿真器。
如果我让setListAdapter执行,就会发生崩溃。如果这条线出去了,一切正常,但显然我的数据没有显示。它不会在调用setListAdapter的行上崩溃,但如果setListAdapter被执行,它最终会崩溃。
堆栈跟踪:
Thread [<3> main] (Suspended (exception StackOverflowError))
ViewRoot.draw(boolean) line: 1235
ViewRoot.performTraversals() line: 1030
ViewRoot.handleMessage(Message) line: 1482
ViewRoot(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 3948
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 782
ZygoteInit.main(String[]) line: 540
NativeStart.main(String[]) line: not available [native method]
在创建SimpleCursorAdapter之前,您是否在光标上调用startManagingCursor? – 2010-08-01 00:16:24
嗨,吉姆,是的,我打电话给startManagingCursor。我查询,管理游标,然后设置列表适配器。我编辑了这篇文章,指出当setListAdapter被调用时崩溃发生。 – Michael 2010-08-01 00:26:16
更新:如果我从包含TabView的活动移动到包含ListActivity的活动,则会发生此错误。 但是,如果我通过选项卡视图以外的方式转到ListActivity,则不会发生崩溃。 – Michael 2010-08-01 00:46:47