Menu overflow 3dot not visible on some devices [closed]

☆樱花仙子☆ 提交于 2020-01-14 06:52:28

问题


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"/>


回答1:


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().



来源:https://stackoverflow.com/questions/27354064/menu-overflow-3dot-not-visible-on-some-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!