私は SQLite データベースで動作する小さなアプリに取り組んでいます...優先度に応じて画像 (緑、黄、または赤) を表示しています。私には3つの優先度(高、中、低...)があり、次のようにそれらのカーソルを取得しています:
cursorh = dbAdapter.fetchAllHighPrio();
cursorm = dbAdapter.fetchAllMedPrio();
cursorl = dbAdapter.fetchAllLowPrio();
次に、次のような他のものを呼び出しています。
startManagingCursor(cursorh);
startManagingCursor(cursorm);
startManagingCursor(cursorl);
String[] from = new String[] { TodoDbAdapter.KEY_SUMMARY };
int[] to = new int[] { R.id.label };
SimpleCursorAdapter noteh = new SimpleCursorAdapter(this,
R.layout.todo_row_high, cursorh, from, to);
SimpleCursorAdapter notem = new SimpleCursorAdapter(this,
R.layout.todo_row_med, cursorm, from, to);
SimpleCursorAdapter notel = new SimpleCursorAdapter(this,
R.layout.todo_row_low, cursorl, from, to);
それで、リストに表示する準備がすべて整いました...しかし、setListAdapterを使用すると、そのうちの1つしか使用できません。カーソルが異なる 3 つの異なるレイアウトがあるため、これを行うのは非常に困難です。これら 3 つの SimpleCursorAdapter をすべてリストに表示するにはどうすればよいですか?
編集:多分私は十分に明確ではなかった...このデータはすべて1つのテーブルにしかありません...しかし、3つの異なるレイアウトがあるため(優先度の色が異なるため)、それらを個別に追加する必要があります...または何かありますか?優先度が「高」の場合、この画像をレイアウトに配置すると、SimpleCursorAdapter が 1 つだけ必要になります。