我怎么可以保存片段?当我旋转屏幕 [英] how can I save the fragment? when I rotate the screen

查看:88
本文介绍了我怎么可以保存片段?当我旋转屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/7951730/viewpager-and-fragments-whats-the-right-way-to-store-fragments-state">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"

这篇关于我怎么可以保存片段?当我旋转屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆