Skip to content Skip to sidebar Skip to footer

How To Force Overflow Menu In Actionbar Using Actionbarsherlock On < 4.0 Devices

Possible Duplicate: ActionBarSherlock & HoloEverywhere - Forcing Overflow? I am using ActionbarSherLock library to display Actionbar on pre-Gingerbread devices.. I want Over

Solution 1:

NOTE: With this suggestion, I am not recommending using ForceOverFlow to any reader. This is simply listing a possibility of making it work (forcing it to work rather). To each his own. Some may want it and like it too. Others may not.

I am probably speculating, but perhaps, this may do it for you.

You can think of this a hack, but I used it before to force the Overflow menu in one of my apps earlier and it works.

try {
    ViewConfiguration config = ViewConfiguration.get(MainPage.this);
    Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
    if (menuKeyField != null) {
        menuKeyField.setAccessible(true);
        menuKeyField.setBoolean(config, false);
    }
} catch (Exception e) {
    e.printStackTrace();
}

Also, the second link by MisterSmith has a solution of sorts with my answer in it. Commonsware has put down some thought about forcing the OverFlow menu here: How To Control use of OverFlow Menu in ICS

EDIT: While typing out this suggestion, you added a comment. To respond to that, I would like to point out that Jake Wharton took out .ForceOverFlow themes. I haven't tried it with version 4.2.0, but with a custom theme, it just might work. If you absolutely must use ForceOverFlow, you might have to use an older version. Read my answer here: https://stackoverflow.com/a/13180285/450534. Something might just make it work.

EDIT 2: As pointed out by the OP in a comment, the Demos Sample APK, in fact, does ForceOverFlow the action bar in Action Modes. I have a feeling, after checking the relevant Java files on github, that the answer to that lies perhaps in 3 Java files.

  1. The Activity ActionModes adds menu items in a very unconventional manner: https://github.com/JakeWharton/ActionBarSherlock/blob/master/samples/demos/src/com/actionbarsherlock/sample/demos/ActionModes.java (Line 53)
  2. The ActionMode Java file in the ABS Library: https://github.com/JakeWharton/ActionBarSherlock/blob/master/library/src/com/actionbarsherlock/view/ActionMode.java
  3. The MenuItem Java file again part of the ABS Library: https://github.com/JakeWharton/ActionBarSherlock/blob/master/library/src/com/actionbarsherlock/view/MenuItem.java

Post a Comment for "How To Force Overflow Menu In Actionbar Using Actionbarsherlock On < 4.0 Devices"