コード例 #1
0
ファイル: AirNotes.java プロジェクト: FusionJT/AirNotes
  private void fillData() {
    // Get all of the rows from the database and create the item list
    mDbHelper.open();
    Cursor airNotesCursor;

    airNotesCursor = mDbHelper.fetchAllNotes();
    startManagingCursor(airNotesCursor);

    String[] from =
        new String[] {
          AirNotesDbAdapter.KEY_CODE,
          AirNotesDbAdapter.KEY_COUNTRY_CODE,
          AirNotesDbAdapter.KEY_DAY,
          AirNotesDbAdapter.KEY_MONTH,
          AirNotesDbAdapter.KEY_YEAR
        };

    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to =
        new int[] {R.id.textCode, R.id.flagCountry, R.id.textDay, R.id.textMonth, R.id.textYear};

    // Now create a simple cursor adapter and set it to display
    AirNoteListAdapter airNotes =
        new AirNoteListAdapter(this, R.layout.airnotes_row, airNotesCursor, from, to);

    setListAdapter(airNotes);
    mDbHelper.close();
  } // fillData
コード例 #2
0
ファイル: AirNotes.java プロジェクト: FusionJT/AirNotes
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case DELETE_ID:
       AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
       mDbHelper.open();
       mDbHelper.deleteAirNote(info.id);
       mDbHelper.close();
       fillData();
       return true;
   } // switch
   return super.onContextItemSelected(item);
 } // onContextItemSelected