I’m working on a little App which works with a SQLite Database… i’m showing a picture (green, yellow or red) which depends on a priority.
i have 3 priorities (high, medium and low…) and i’m getting those cursors as following:
cursorh = dbAdapter.fetchAllHighPrio();
cursorm = dbAdapter.fetchAllMedPrio();
cursorl = dbAdapter.fetchAllLowPrio();
Then i’m calling some other stuff like this:
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);
so then i have all of my stuff prepared to show on my list… but if i use setListAdapter i can only use 1 of them. since i have 3 different layouts with the different cursors, this is really pretty hard to do.
How can i get all those 3 SimpleCursorAdapters to show in my list now?
EDIT: Maybe i wasnt clear enough… All of this data is in only one table… but since i have 3 different layouts (because of the different priority colors) i need to add them seperately… or is there any other way of just saying like if the priority equals ‘high’ put this image in layout so i only need one SimpleCursorAdapter?
You can create a VIEW that would combine data from all 3 tables + an extra column to tell which table the data came from. Then you query from it and return appropriate row
Views in a customCursorAdapter.