The display of the menu button on ICS when saving android: targetSdkVersion will be 14

I have an existing full-screen view application that uses the menu button to display options. I set android: targetSdkVersion to 14 so that the whole theme of the application looks like a native ICS APP.

The problem is that when I set the Activity style in full screen mode, I donโ€™t have a menu button, and if I show an ActionBar, it takes up too much space on the screen to display the menu.

Is there a way to save the regular menu button in full screen on ICS?

+5
source share
2 answers

, ICS - , . - - " ". , SDK: android.os.Build.VERSION.SDK_INT

+2

, . . , . Android .

public static void addLegacyOverflowButton(Window window) {
  if (window.peekDecorView() == null) {
    throw new RuntimeException("Must call addLegacyOverflowButton() after setContentView()");
  }

  try {
    window.addFlags(WindowManager.LayoutParams.class.getField("FLAG_NEEDS_MENU_KEY").getInt(null));
  }
  catch (NoSuchFieldException e) {
    // Ignore since this field won't exist in most versions of Android
  }
  catch (IllegalAccessException e) {
    Log.w(TAG, "Could not access FLAG_NEEDS_MENU_KEY in addLegacyOverflowButton()", e);
  }
}
+2

All Articles