我有一個活動在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