summaryrefslogtreecommitdiffstats
path: root/tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java
diff options
context:
space:
mode:
authorTom O'Neill <tomo@google.com>2009-12-15 11:27:15 -0800
committerTom O'Neill <tomo@google.com>2009-12-16 09:54:24 -0800
commit77560fc704f2933e0df8a4be0768b2439a0bab2a (patch)
treeb42a79fbe8648db3bca5c2f1c0dd19c4670262ba /tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java
parent7a416277107f8ae46831fe8c5501f7e618a37f3e (diff)
downloadandroid_development-77560fc704f2933e0df8a4be0768b2439a0bab2a.tar.gz
android_development-77560fc704f2933e0df8a4be0768b2439a0bab2a.tar.bz2
android_development-77560fc704f2933e0df8a4be0768b2439a0bab2a.zip
Finish adding Makefiles for the Notepad tutorial.
Add the missing makefiles for the non-solution versions of the tutorial code. Required providing missing imports in Notepadv2. Also standardized white spaces using Source > Correct Indentation in Eclipse and a few manual changes. This was done to minimize differences such as: diff -r Notepadv1 Notepadv1Solution diff -r Notepadv1Solution/src/com/android/demo/notepad1/ Notepadv2/src/com/android/demo/notepad2/ Change-Id: Ie8b10efd61f2200b3c741ea500a6924710ab54ed
Diffstat (limited to 'tutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java')
-rwxr-xr-xtutorials/NotepadCodeLab/Notepadv3Solution/src/com/android/demo/notepad3/NoteEdit.java39
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);
}
}
-
+
}