我正在尝试根据我的SQLite DB中的信息创建一个列表视图.我目前设置的代码只是相应地显示每一行,并用数据填充3个textviews.我希望能够使用某种If语句来检查其中一个值是否为"Room1",然后将该行的背景设置为某种颜色.
这样,列表中的每一行将根据数据的"空间"具有不同的背景.
我试过扩展SimpleCursorAdapter,但是我对如何得到我想要的东西感到有点迷茫.
以下是我目前对SimpleCursorAdapter的看法:
Cursor notesCursor = myDbHelper.fetchDayPanelNotes(type, day);
startManagingCursor(notesCursor);
String[] from = new String[]{DataBaseHelper.KEY_NAME, DataBaseHelper.KEY_ROOM, DataBaseHelper.KEY_TIME};
int[] to = new int[]{R.id.text1, R.id.text2, R.id.text3};
SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.main_row, notesCursor, from, to);
setListAdapter(notes);
Run Code Online (Sandbox Code Playgroud)