我正在研究一個適用於SQLite數據庫的小應用程序......我顯示的圖片(綠色,黃色或紅色)取決於優先級。 我有3個優先級(高,中,低...),我得到那些光標如下:Android多個SimpleCursorAdapter
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,我只能使用其中的一個。因爲我有3種不同的遊標佈局,這真的很難做到。 我怎樣才能讓所有這3個SimpleCursorAdapters現在顯示在我的列表中?
編輯:也許我沒有足夠清楚......所有這些數據都只在一張桌子......但因爲我有3種不同的佈局(因爲不同的優先顏色)我需要單獨添加它們......或者有沒有其他方式只是說,如果優先級等於'高'把這個圖像佈局,所以我只需要一個SimpleCursorAdapter?
之類的適配器請看上面@我的編輯...我把我所有的數據放在同一張表中...... – user754730 2011-05-17 11:43:27
這使得它更容易。您需要一個單獨的遊標(可能按優先級排序),「CursorAdapter」將根據優先級返回不同的「視圖」。 – yanchenko 2011-05-17 12:20:56
以及如何返回這些不同的意見?我有方法讓他們回來排序,但我怎麼能說哪個優先使用哪種佈局? – user754730 2011-05-17 12:26:02