1

I have an options menu, but don't want it to appear when the screen is flipped horizontal. I have the following method to determine lanscape, but need to know how to disable the options menu.

private boolean isLandscape() {
        if (Configuration.ORIENTATION_LANDSCAPE == getResources().getConfiguration().orientation) {
            return true;
        } else {
            return false;
        }
    }
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556

2 Answers2

5
public boolean onPrepareOptionsMenu (Menu menu) {
  return !isLandscape();
}

See the documentation for more info.

dmon
  • 30,048
  • 8
  • 87
  • 96
-1
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
David Arenburg
  • 91,361
  • 17
  • 137
  • 196