我有一个活动在Sqlite数据库上运行查询,获取游标,使用该游标创建CustomCursorAdapter,并将其附加到活动中的ListView。它看起来像这样:避免使用游标的ANR
SQLiteDatabase db=new StuffHelper(this).getWritableDatabase();
Cursor c1=db.query(StuffHelper.TABLE,
new String[]{StuffHelper._ID},
StuffHelper.SIZE+">=?",
new String[]{"64"},
null,
null,
null);
startManagingCursor(c1);
StuffAdapter a1 = new StuffAdapter(this, c1);
ListView ll1 = (ListView) findViewById(R.id.ll1);
ll1.setAdapter(a1);
这是目前的设置ANR方面的问题吗?当使用游标时,我如何告诉android在后台线程上运行所有Sqlite的东西?
“可以创建并分配ListAdapter没有到光标任何引用(我会建议你尽快修复“。如果你看看SimpleCursorAdapter这样的东西,它需要在构造函数中使用Cursor。 – yydl 2011-06-16 05:20:03
嗯:'m_listAdapter = new ArrayAdapter((Conte XT)这个,R.layout.list_row,R.id.rowText,m_arrayList){ \t \t \t \t @覆盖 \t \t公共查看getView(INT位置,查看convertView,ViewGroup以及母公司){...}} setListAdapter (m_listAdapter);'格式不正确,但是,嘿,我分配了一个列表适配器,而没有制作游标。 –
Pedantic
2011-06-16 05:23:28
使用'SimpleCursorAdapter'应该认真考虑Android反模式,并从所有教程和示例代码中受到影响。 – Pedantic 2011-06-16 05:28:33