2016-07-14 6 views

答えて

0

画面の向きを設定することができます。

Button button = (Button) findViewById(R.id.button); 
button.setOnClickListener(new Button.OnClickListener(){ 
    @Override 
    public void onClick(View arg0) { 
      //This line will set the orientation to landscape. 
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
    } 
} 

ACTIVITYINFOクラスの値を使用するだけで済みます。

リソース

ActivityInfo:https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_LANDSCAPE

景観:https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_LANDSCAPE

ポートレート:https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_PORTRAIT

関連する問題