Instead of using something global like android: configChanges that affect ALL views in an Activity, how about using the setSaveEnabled (boolean) method or the equivalent android: saveEnabled xml attribute?
Controls whether or not to save this view state (that is, whether its onSaveInstanceState () method will be called).
If you set it to false, you always need to return to the default state when you change the orientation, because its state will not be saved.
You could, for example, put this in a layout file:
<ListView .... android:visibility="invisible" android:saveEnabled="false"> </ListView>
and then set the visibility to VISIBLE when you start typing. Or, if you prefer to use the visibility and setSaveEnabled method in the onCreate method.
I tried with a simple ListView and Button that changes the visibility to true. When rotated, the ListView became invisible (its default state)
Also note:
This flag can only disable saving this view; all child views can keep their state.
so you need to clear the list during onStop () or any other method you want, but even if you don't, the ListView will still be invisible when rotated
A source:
fabiolbr
source share