我的Android应用程序出现问题。当我旋转手机(onCreate被调用)时,我的活动重新开始。我有googlet,并尝试 android:configChanges="keyboardHidden|orientation">
在我的表现,但没有运气。可有人请向我解释如何我能得到这个工作旋转重新启动活动
编辑:我发现我NEDD到广告这些代码
清单
<activity
android:name="?"
android:label="@string/?"
android:theme="@style/?"
android:configChanges="orientation|screenSize">
MainActivity
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
}
}
可以相应地重新加载旋转数据,或将其锁定为纵向|景观。 – Doomsknight 2013-05-03 21:40:34
如何重新加载旋转的数据? – Thor1401 2013-05-05 00:19:13
重新启动配置更改的活动是Android上的正确和自然行为。只需使用onSaveInstanceState来保存您想要在旋转过程中保留的数据。 – Teovald 2013-05-05 12:50:29