javaandroidmenuandroid-2.2-froyooptions-menu

How to disable options menu for landscape view?


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;
        }
    }

Solution

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

    See the documentation for more info.