[英]Android: Getting orientation (landscape/portrait) on Activity launch
我的活動需要監控設備的方向。 現在這對onConfigurationChanged()
非常onConfigurationChanged()
,但是當我的Activity開始時我也需要知道方向。
那么如何在我的onCreate()
找出設備的當前方向呢?
我不是專家,但這對我onCreate()
,在onCreate()
:
int display_mode = getResources().getConfiguration().orientation;
if (display_mode == Configuration.ORIENTATION_PORTRAIT) {
setContentView(R.layout.main);
} else {
setContentView(R.layout.main_land);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.