Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Instead of using something global like <em>android:configChanges</em> which affect ALL the views in the Activity, what about using the method <strong>setSaveEnabled(boolean)</strong> or the equivalent xml attribute <strong>android:saveEnabled</strong> ?</p> <blockquote> <p>Controls whether the saving of this view's state is enabled (that is, whether its onSaveInstanceState() method will be called).</p> </blockquote> <p>If you set it to false it should always go back to the default state when changing orientation because its state won't be saved.</p> <p>You could, for example, put this in the layout file:</p> <pre><code>&lt;ListView .... android:visibility="invisible" android:saveEnabled="false"&gt; &lt;/ListView&gt; </code></pre> <p>and then set the visibility to VISIBLE when you start typing. Or if you prefer put the visibility and the method <em>setSaveEnabled</em> in the onCreate method.</p> <p>I tried with a simple ListView and a Button that changes the visibility to true. On rotation the ListView became invisibile(its default state)</p> <p>Also note that:</p> <blockquote> <p>This flag can only disable the saving of this view; any child views may still have their state saved.</p> </blockquote> <p>so you should have to clear the list during onStop() or whatever method you want but if even if you don't, the ListView will still be invisible on rotation</p> <p>Source:</p> <ul> <li><a href="http://developer.android.com/reference/android/view/View.html#attr_android:saveEnabled" rel="noreferrer">http://developer.android.com/reference/android/view/View.html#attr_android:saveEnabled</a></li> <li><a href="http://developer.android.com/reference/android/view/View.html#setSaveEnabled%28boolean%29" rel="noreferrer">http://developer.android.com/reference/android/view/View.html#setSaveEnabled%28boolean%29</a></li> </ul>
 

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