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

2 に答える 2

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

See the documentation for more info.

于 2011-06-16T04:26:18.437 に答える
-1
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
于 2016-03-27T05:08:50.747 に答える