Loading docs/html/resources/tutorials/notepad/codelab/NotepadCodeLab.zip −2.26 KiB (86.5 KiB) File changed.No diff preview for this file type. View original file View changed file docs/html/resources/tutorials/notepad/notepad-ex2.jd +55 −55 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ public boolean onCreateContextMenu(Menu menu, View v super.onCreateContextMenu(menu, v, menuInfo); menu.add(0, DELETE_ID, 0, R.string.menu_delete); }</pre> <p>The <code>onCreateContextMenu()</code> callback some passes other information in addition to the Menu object, <p>The <code>onCreateContextMenu()</code> callback passes some other information in addition to the Menu object, such as the View that has been triggered for the menu and an extra object that may contain additional information about the object selected. However, we don't care about these here, because we only have one kind of object in the Activity that uses context menus. In the next Loading Loading @@ -613,7 +613,7 @@ protected void onCreate(Bundle savedInstanceState) { <code>AndroidManifest.xml</code> file and look at the source (use the <code>AndroidManifest.xml</code> tab in the eclipse editor to see the source code directly). Then edit the file as follows:<br> <code><activity android:name=".NoteEdit"></activity></code><br><br> <code><activity android:name=".NoteEdit" /></code><br><br> This should be placed just below the line that reads:<br> <code></activity></code> for the <code>.Notepadv2</code> activity.</p> Loading docs/html/resources/tutorials/notepad/notepad-ex3.jd +46 −37 Original line number Diff line number Diff line Loading @@ -87,8 +87,8 @@ if (body != null) { </pre> with this: <pre> mRowId = savedInstanceState != null ? savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID) : null; 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) Loading @@ -102,6 +102,11 @@ if (body != null) { provided by the <code>savedInstanceState</code>. This is a ternary operator shorthand to safely either use the value or null if it is not present. </li> <li> Note the use of <code>Bundle.getSerializable()</code> instead of <code>Bundle.getLong()</code>. The latter encoding returns a <code>long</code> primitive and so can not be used to represent the case when <code>mRowId</code> is <code>null</code>. </li> </ol> <h2>Step 4</h2> Loading Loading @@ -141,8 +146,8 @@ mBodyText = (EditText) findViewById(R.id.body); Button confirmButton = (Button) findViewById(R.id.confirm); mRowId = savedInstanceState != null ? savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID) : null; 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) Loading Loading @@ -241,8 +246,10 @@ and populate the View elements with them.</p> @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putLong(NotesDbAdapter.KEY_ROWID, mRowId); saveState(); outState.putSerializable(NotesDbAdapter.KEY_ROWID, mRowId); }</pre> <p>We'll define <code>saveState()</code> next.</p> </li> <li><code> onPause()</code>: Loading @@ -252,7 +259,6 @@ and populate the View elements with them.</p> super.onPause(); saveState(); }</pre> <p>We'll define <code>saveState()</code> next.</p> </li> <li><code> onResume()</code>: Loading @@ -264,6 +270,10 @@ and populate the View elements with them.</p> }</pre> </li> </ol> <p>Note that <code>saveState()</code> must be called in both <code>onSaveInstanceState()</code> and <code>onPause()</code> to ensure that the data is saved. This is because there is no guarantee that <code>onSaveInstanceState()</code> will be called and because when it <em>is</em> called, it is called before <code>onPause()</code>.</p> <h2 style="clear:right;">Step 8</h2> Loading Loading @@ -301,8 +311,7 @@ database.</p> necessary. The resulting method should look like this:</p> <pre> @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); fillData(); }</pre> Loading Loading
docs/html/resources/tutorials/notepad/codelab/NotepadCodeLab.zip −2.26 KiB (86.5 KiB) File changed.No diff preview for this file type. View original file View changed file
docs/html/resources/tutorials/notepad/notepad-ex2.jd +55 −55 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ public boolean onCreateContextMenu(Menu menu, View v super.onCreateContextMenu(menu, v, menuInfo); menu.add(0, DELETE_ID, 0, R.string.menu_delete); }</pre> <p>The <code>onCreateContextMenu()</code> callback some passes other information in addition to the Menu object, <p>The <code>onCreateContextMenu()</code> callback passes some other information in addition to the Menu object, such as the View that has been triggered for the menu and an extra object that may contain additional information about the object selected. However, we don't care about these here, because we only have one kind of object in the Activity that uses context menus. In the next Loading Loading @@ -613,7 +613,7 @@ protected void onCreate(Bundle savedInstanceState) { <code>AndroidManifest.xml</code> file and look at the source (use the <code>AndroidManifest.xml</code> tab in the eclipse editor to see the source code directly). Then edit the file as follows:<br> <code><activity android:name=".NoteEdit"></activity></code><br><br> <code><activity android:name=".NoteEdit" /></code><br><br> This should be placed just below the line that reads:<br> <code></activity></code> for the <code>.Notepadv2</code> activity.</p> Loading
docs/html/resources/tutorials/notepad/notepad-ex3.jd +46 −37 Original line number Diff line number Diff line Loading @@ -87,8 +87,8 @@ if (body != null) { </pre> with this: <pre> mRowId = savedInstanceState != null ? savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID) : null; 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) Loading @@ -102,6 +102,11 @@ if (body != null) { provided by the <code>savedInstanceState</code>. This is a ternary operator shorthand to safely either use the value or null if it is not present. </li> <li> Note the use of <code>Bundle.getSerializable()</code> instead of <code>Bundle.getLong()</code>. The latter encoding returns a <code>long</code> primitive and so can not be used to represent the case when <code>mRowId</code> is <code>null</code>. </li> </ol> <h2>Step 4</h2> Loading Loading @@ -141,8 +146,8 @@ mBodyText = (EditText) findViewById(R.id.body); Button confirmButton = (Button) findViewById(R.id.confirm); mRowId = savedInstanceState != null ? savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID) : null; 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) Loading Loading @@ -241,8 +246,10 @@ and populate the View elements with them.</p> @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putLong(NotesDbAdapter.KEY_ROWID, mRowId); saveState(); outState.putSerializable(NotesDbAdapter.KEY_ROWID, mRowId); }</pre> <p>We'll define <code>saveState()</code> next.</p> </li> <li><code> onPause()</code>: Loading @@ -252,7 +259,6 @@ and populate the View elements with them.</p> super.onPause(); saveState(); }</pre> <p>We'll define <code>saveState()</code> next.</p> </li> <li><code> onResume()</code>: Loading @@ -264,6 +270,10 @@ and populate the View elements with them.</p> }</pre> </li> </ol> <p>Note that <code>saveState()</code> must be called in both <code>onSaveInstanceState()</code> and <code>onPause()</code> to ensure that the data is saved. This is because there is no guarantee that <code>onSaveInstanceState()</code> will be called and because when it <em>is</em> called, it is called before <code>onPause()</code>.</p> <h2 style="clear:right;">Step 8</h2> Loading Loading @@ -301,8 +311,7 @@ database.</p> necessary. The resulting method should look like this:</p> <pre> @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); fillData(); }</pre> Loading