Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In order to save the state of View's within activities in Android you need to implement the <code>onSaveInstanceState(Bundle outState)</code> and <code>onRestoreInstanceState(Bundle savedInstanceState)</code> methods. See the <a href="http://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges" rel="nofollow">Android Developer Guide</a> for more on these methods.</p> <p><code>onSaveInstanceState(Bundle outState)</code> is called when the activity is destroyed on configuration change (change in orientation). You can add data to the bundle in this method and then retrieve it when the activity is restarted using <code>onRestoreInstanceState(Bundle savedInstanceState)</code>.</p> <p>For example:</p> <pre><code>@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); // Read values from the "savedInstanceState" bundle and put them back into the corresponding textviews } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Save the values you need from your textviews into the outState object } </code></pre> <p>For more details on how to save data into bundles see the <a href="http://developer.android.com/training/basics/activity-lifecycle/recreating.html" rel="nofollow">Android Developer Guide</a>. This also explains the difference between restoring state using <code>onCreate(Bundle savedInstanceState)</code> and <code>onRestoreInstanceState(Bundle savedInstanceState)</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload