Im working on the notepad tutorial from the android website. I have created a database with 2 entries: name and address. When the application is run only the Name is displayed. I want to display both Name and address. I have edited my filldata method but it doesnt work. See my code below. Any suggestions?
private void fillData() {
Cursor notesCursor = mDbHelper.fetchAllNotes();
startManagingCursor(notesCursor);
// Create an array to specify the fields we want to display in the list (TITLE + BODY)
String[] from = new String[]{NotesDbAdapter.KEY_TITLE,NotesDbAdapter.KEY_BODY};
// and an array of the fields we want to bind those fields to (in this case just text1)
int[] to = new int[]{R.id.text1};
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row, notesCursor, from, to);
setListAdapter(notes);
}
In your
R.layout.notes_rowfile you should have twoTextViewsone for the title and one for the address and then you will write:Edit:
R.layout.notes_rowcould be something like this: