I'm creating an Android app, where the user starts out seeing a list of questions. When the user clicks a question, I would like to show him a new clickable list, containing that question and its answer alternatives.
My questions reside in rows in the database. The questions live in the first column, while the answer alternatives live in the following columns.
I've managed to display any single element from the row when I click a question in the list, but how to display more than one completely eludes me.
This is the relevant source code in the intent entered when the user clicks a question:
private void fillData() {
Bundle extras = getIntent().getExtras();
Long id = extras != null ? extras.getLong(QuestionsDbAdapter.KEY_ROWID) : null;
Cursor questionsCursor = mDbHelper.fetchQuestion(id);
startManagingCursor(questionsCursor);
String[] from = new String[]{mDbHelper.KEY_QUESTION,
mDbHelper.KEY_ALT1,mDbHelper.KEY_ALT2};
int[] to = new int[]{R.id.text1};
SimpleCursorAdapter questions =
new SimpleCursorAdapter(this, R.layout.questions_one_row,
questionsCursor, from,to);
setListAdapter(questions);
}
This displays only the question. If I put one of the answer alternatives first in the 'String[] from ...' statement, that gets displayed instead.