当我将设备从纵向转为横向时,我的活动将重新启动。对于该活动,我需要同时使用纵向和横向模式。
如何展示我的Activity
?
答案 0 :(得分:2)
在清单文件android:configChanges="orientation|keyboardHidden"
中添加此行
<activity android:name=".imgview"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
并且你可以覆盖重启。在我的函数中,它是更新列表项和其他一些函数:example
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.e("ScreenMode",""+screenMode);
if(screenMode==1)
{Log.e("ScreenMode",""+screenMode);
buildUrl(result,startPage);
showImageList();
}
if(screenMode==2)
{
showOneImage(forFunc);
}
if(screenMode==0)
{
startOMG();
}
}
答案 1 :(得分:0)
为避免重新启动,请在android:configChanges="keyboardHidden|orientation"
AndroidManifest
中使用Activity
。