我怎么可以保存片段?当我旋转屏幕当我、片段、屏幕、我怎么

2023-09-06 03:44:35 作者:闭眼听风

可能重复:   ViewPager和片段 - 什么是正确的方式来存储片段的状态

我怎么可以保存片段? (它位于活动)当我旋转屏幕,该活动正在重新启动,重新创建片段

how can I save the fragment? (It is located at the activity) When I rotate the screen, the activity being restarted, fragment is re-created

推荐答案

您需要添加的定向为安卓configChanges 在AndroidManifest.xml中。每例如:

You need to add orientation to android:configChanges in your AndroidManifest.xml. Per example:

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