0

我正在使用标签小部件。当我的孩子活动正在运行并且我改变方向时,孩子活动被破坏。

作为这个问题的解决方案,我 android:configChanges="orientation|keyboardHidden在 manifest.xml 文件中添加了所有活动标签。

我发现我的应用程序没有从layout_land文件夹中获取 xml 文件。

谁能给我这个查询的解决方案?

提前致谢。

我发现使用onConfigurationChanged方法我可以知道方向,我必须在布局文件夹而不是文件夹中设置横向文件layout_land

 @Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
        setContentView(R.layout.login_landscape);
    }
    else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        setContentView(R.layout.login);         
    }
}
4

1 回答 1

0

发生这种情况是因为您的 Activity 没有被销毁,因为您已放入android:configChanges="orientation|keyboardHidden"清单,因此setContentView当方向更改时不会调用它,因此它不会layoutlayout_land

更新:这不是你Tab-Activity正常尝试的问题,activity它不会选择正确的layout,或者一般来说没有layout选择你portrait layout只是旋转显示在landscape

于 2011-12-14T06:35:03.373 回答