I'm working through the Notepad example, and I'm right at the end of v1. Everything works, I've even added a few small things by playing around with the layout and such. But I just don't understand how R.layout.notepad_list knows to populate itself with the R.layout.notes_row rows. I see how the database cursor is hooked up to populate the rows in this line:
private void fillData() {
....
SimpleCursorAdapter notesAdapter =
new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
....
}
And I see how the notepad_list is set as the content view in this line:
public void onCreate(Bundle savedInstanceState) {
....
setContentView(R.layout.notepad_list);
....
}
But how does ListView know to use the rows created by the SimpleCursorAdapter? Is it this line:
private void fillData() {
....
setListAdapter(notes);
....
}
The help text for setListAdapter is:
void android.app.ListActivity.setListAdapter(ListAdapter adapter)
public void setListAdapter(ListAdapter adapter) Since: API Level 1
Provide the cursor for the list view.
But couldn't I have two ListViews inside notepad_list.xml? How would the code know which one to populate with the data from the cursor?