diff options
| author | Android (Google) Code Review <android-gerrit@google.com> | 2009-12-16 11:29:36 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-12-16 11:29:36 -0800 |
| commit | 068f3dd6a112fe3311ace2fe98458a0176bed562 (patch) | |
| tree | 67b112b04f45c76345dc9101277c87e74358ad18 /tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java | |
| parent | 91f556a237e865cfe0daa2b467170c58278e4bea (diff) | |
| parent | 77560fc704f2933e0df8a4be0768b2439a0bab2a (diff) | |
Merge change Ie8b10efd
* changes:
Finish adding Makefiles for the Notepad tutorial.
Diffstat (limited to 'tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java')
| -rwxr-xr-x | tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java b/tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java index f5eb6c433..eabb07a4e 100755 --- a/tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java +++ b/tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java @@ -25,7 +25,7 @@ import android.widget.EditText; public class NoteEdit extends Activity { - private EditText mTitleText; + private EditText mTitleText; private EditText mBodyText; private Long mRowId; private NotesDbAdapter mDbHelper; @@ -36,63 +36,62 @@ public class NoteEdit extends Activity { mDbHelper = new NotesDbAdapter(this); mDbHelper.open(); setContentView(R.layout.note_edit); - - + + mTitleText = (EditText) findViewById(R.id.title); mBodyText = (EditText) findViewById(R.id.body); - + Button confirmButton = (Button) findViewById(R.id.confirm); - mRowId = (savedInstanceState == null) ? null : (Long) savedInstanceState.getSerializable(NotesDbAdapter.KEY_ROWID); if (mRowId == null) { - Bundle extras = getIntent().getExtras(); - mRowId = extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID) + Bundle extras = getIntent().getExtras(); + mRowId = extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null; } populateFields(); - + confirmButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - setResult(RESULT_OK); - finish(); - } - + public void onClick(View view) { + setResult(RESULT_OK); + finish(); + } + }); } - + private void populateFields() { if (mRowId != null) { Cursor note = mDbHelper.fetchNote(mRowId); startManagingCursor(note); mTitleText.setText(note.getString( - note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE))); + note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE))); mBodyText.setText(note.getString( note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY))); } } - + @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); saveState(); outState.putSerializable(NotesDbAdapter.KEY_ROWID, mRowId); } - + @Override protected void onPause() { super.onPause(); saveState(); } - + @Override protected void onResume() { super.onResume(); populateFields(); } - + private void saveState() { String title = mTitleText.getText().toString(); String body = mBodyText.getText().toString(); @@ -106,5 +105,5 @@ public class NoteEdit extends Activity { mDbHelper.updateNote(mRowId, title, body); } } - + } |
