我在用onConfigurationChanged().在那里,当我从LandScape改为Portrait时,它正在调用if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)并从LandScape转移到Portrait.但是当我从Portrait改为Land-Scape时,它并没有改变为LandScape,因为它正在调用if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)它,它并没有从LandScape变为Portrait.请帮忙.
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
//int orientation = this.getResources().getConfiguration().orientation;
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Log.d("Entered to change as Portrait ","PPPPPPPPPPPPPPPPP");
setContentView(R.layout.settings);
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.d("Entered to change as LandScape ","LLLLLLLLLLLLLLLLLLLL");
setContentView(R.layout.settings);
}
}
Run Code Online (Sandbox Code Playgroud) android ×1