Beginning from ActionbarSherlock 4.2 we’ve lost the ability to manage overflow menu visibility.
To make it working, you need combine 2 approaches:
-
To force menu visibility for Android 3.x (honeycomb) and upper, you need use this hack + add check Android version:
public static final int DEVICE_VERSION = Build.VERSION.SDK_INT; public static final int DEVICE_HONEYCOMB = Build.VERSION_CODES.HONEYCOMB; if (DEVICE_VERSION >= DEVICE_HONEYCOMB) // Code from answer above
-
Open menu for pre-honeycomb devices:
- Open
ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java
, go to methodreserveOverflow
-
Replace the original with:
public static boolean reserveOverflow(Context context) {
return true;
}
This will force menu showing …
-
but when click on menu button menu popup not showing. To achieve this we need override this in your activity class:
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (DEVICE_VERSION < DEVICE_HONEYCOMB) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_MENU) { openOptionsMenu(); return true; } } return super.onKeyUp(keyCode, event); }
- Open
After this actions you should have absolutely working overflow action bar menu for all Android versions.