Here is my code:
private void fillData() {
Cursor notesCursor = mDbHelper.fetchAllNotes();
startManagingCursor(notesCursor);
String[] from = new String[]{NotesDbAdapter.KEY_TITLE, NotesDbAdapter.KEY_COLOR};
int[] to = new int[]{R.id.text1, R.id.text2};
SimpleCursorAdapter notes = new SimpleCursorAdapter(
this, R.layout.note_row, notesCursor, from, to);
setListAdapter(notes);
}
Which produces the following ListView: https://i.stack.imgur.com/7W1xa.jpg
What I want is to take "R.id.text2" value (which is a hex color) and set it as text color of itself, for each different row of my ListView.
The result should look like this: https://i.stack.imgur.com/wrXt8.jpg
Is that possible? Thanks.
Yes, it's possible. Create your own cursor adapter
MyCursorAdapter
which extendSimpleCursorAdapter
, then overridenewView
orbindView
method.