安卓:省钱,屏幕方向变化的应用程序状态 [英] Android : Save application state on screen orientation change
问题描述
我已经看到下面的链接张贴这个问题之前,
I have seen the following links before posting this question
http://www.devx.com/wireless/Article/40792/1954
http://www.gitshah.com/ 2011/03 /如何到手柄屏幕,orientation_28.html
<一个href="http://stackoverflow.com/questions/3915952/how-to-save-state-during-orientation-change-in-android-if-the-state-is-made-of-m">How期间方向改变Android的保存状态,如果状态是由我的课吗?
我没有得到我应该如何重写以下功能:
I am not getting how should i override the following function :
@Override
public Object onRetainNonConfigurationInstance() {
return someExpensiveObject;
}
在我的应用程序,我有一个editext可见光和其他布局editext得到明显的验证时,首先editext的数据,真实的。我已经将所有其他editextes和textviews假的visbility,让他们验证后可见。
In my application i have layout with one editext visible and other editext get visible when the data of first editext validates to true.I have set the visbility of all other editextes and textviews to false and make them visible after validating.
所以在我的活动如果屏幕方向改变,则所有具有项目机器人:能见度=假
获得无形
So in my activity if the screen orientation is changed then all the items having android:visibility="false"
get invisible.
我也才知道,当我们的活动,屏幕方向变化,它调用的onStop()之后的onDestroy(),然后再通过调用的onCreate开始一个新的活动()
I have also came to know that when our activities screen orientation changes it calls onStop() followed by onDestroy() and then again starts a fresh activity by calling onCreate()
这是原因。但我没有得到如何解决它。
This is the cause .. But i am not getting how to resolve it ..
在这里你可以看到我的应用程序的截图:
Here You can see the screenshots of my application :
在这个图像中的所有字段都加载 而在另一个图像时,屏幕方向改变为横向,他们都走了
in this image all fields are loaded and in another image when the screen orientation is changed to landscape they are all gone
任何链接到教程或一张code就会有强烈的AP preciable。
Any link to tutorial or piece of code will be highly appreciable.
也是一个进度对话框显示了,我试图改变屏幕orientation.How来处理这个?当我的应用程序崩溃
And also my application crashes when a progress dialog is shown up and i try to change screen orientation.How to handle this ??
感谢
推荐答案
那么如果你有相同的布局
对两个画面那么就没有必要这么做只是添加下面一行的清单
在活动
节点
Well if you have the same layout
for both screens then there is no need to do so just add below line in your manifest
in Activity
node
android:configChanges="keyboardHidden|orientation"
为Android 3.2(API级别13)和新的:
for Android 3.2 (API level 13) and newer:
android:configChanges="keyboardHidden|orientation|screenSize"
因为屏幕尺寸也改变时,该设备纵向和横向之间切换。文档在这里: http://developer.android.com/guide/topics/清单/活性element.html
这篇关于安卓:省钱,屏幕方向变化的应用程序状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!