我正在使用标签小部件。当我的孩子活动正在运行并且我改变方向时,孩子活动被破坏。
作为这个问题的解决方案,我
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);
}
}