[英]Change layout when screen is rotated and maintain activity state in android
I'm not using configChanges attribute to my activity in manifest as I need to show a different layout for landscape mode. 我没有在清单中的活动中使用configChanges属性,因为我需要显示横向模式的其他布局。 And saving few primitive data values in onSaveInstanceState() method and getting back in Bundle of onCreate().
并在onSaveInstanceState()方法中保存一些原始数据值,并返回到onCreate()捆绑包中。 Here are my issues :
这是我的问题:
You should probably add this in your manifest file first (note the configChanges
): 您可能应该首先将其添加到清单文件中(注意
configChanges
):
<activity android:name=".MyActivity"
android:configChanges="orientation"
android:label="@string/app_name">
Then override these two methods and do what you want with the data inside onSaveInstanceState()
, onRestoreInstanceState()
. 然后重写这两个方法,并使用
onSaveInstanceState()
和onRestoreInstanceState()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.