How to save a fragment? when i rotate the screen

Possible duplicate:
ViewPager and slices - what is the way to save fragment state?

How to save a fragment? (He is in action) When I rotate the screen, restarting the action, the fragment is recreated enter image description here

+4
source share
2 answers

You need to add orientation in android: configChanges in your AndroidManifest.xml. For instance:

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" 
-1
source

try using setRetainInstance(true); in your onCreate snippet

+13
source

Source: https://habr.com/ru/post/1432267/


All Articles