Hello All! I just do the exercise 2 in tutorial document, and I have a question in the onMenuItemSelected function.
@Override public boolean onMenuItemSelected(int featureId, Item item) { switch(item.getId()) { case INSERT_ID: createNote(); return true; case DELETE_ID: mDbHelper.deleteNote(getListView().getSelectedItemId()); fillData(); return true; } return super.onMenuItemSelected(featureId, item); } when I delete the note,the code will call getSelectedItemId() to get the id of the row. But I don't specify the the "id" field in fillData(). only the "text1" field was passed to the Constructor of SimpleCursorAdapter, how can the getSelectedItemId function to get the id? SimpleCursorAdapter will automatic add the id field? Somebody know why? Thanks! private void fillData() { // Get all of the rows from the database and create the item list mNotesCursor = mDbHelper.fetchAllNotes(); startManagingCursor(mNotesCursor); // Create an array to specify the fields we want to display in the list (only TITLE) String[] from = new String[]{NotesDbAdapter.KEY_TITLE}; // 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, mNotesCursor, from, to); setListAdapter(notes); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---