2010-08-28 111 views

回答

20

我不是專家,但是這個工作對我來說,在onCreate()

int display_mode = getResources().getConfiguration().orientation; 

if (display_mode == Configuration.ORIENTATION_PORTRAIT) { 
    setContentView(R.layout.main); 
} else { 
    setContentView(R.layout.main_land); 
}       
+0

我一直在尋找在'Activity'爲'getConfiguration()'方法...安卓你爲什麼要如此遲鈍。謝謝ShadowGod! – 2010-08-28 04:58:23

+11

你沒有理由以這種方式設置你的觀點。 Android是自動構建的,可以根據文件夾位置使用正確的。您可以將相同名稱的默認佈局/ res/layout /和風景佈置在/ res/layout-land中。在onCreate Android期間檢測佈局並使用正確的資源。屏幕密度和其他事情也可以做到這一點。 – smith324 2010-08-28 05:12:45

+0

Ahhh感謝克里斯作爲初學者我沒有意識到,謝謝。 – ShadowGod 2010-08-28 05:21:03

相關問題