-2

Devices which have menu button on that overflow button not showing

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >

<item
    android:id="@+id/incoming"
    android:showAsAction="always"
    android:title="Incoming Call Control"/>
<item
    android:id="@+id/list"
    android:showAsAction="always"
    android:title="Active Filter List"/>

Hii
  • 23
  • 7

1 Answers1

2

Its not visible on devices which have the hardware menu button. To enable the action overflow icon, there is a dirty hack that you can do in your application.

private void getOverflowMenu() {

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

Call the above method in your application class onCreate().

Antrromet
  • 15,294
  • 10
  • 60
  • 75