操作栏图标未显示在Nexus的操作栏中

时间:2015-12-29 07:05:02

标签: android android-layout

我做了很多搜索,但无法解决我的错误。请帮忙!!

我之前获得了这些选项而且工作正常,但在做了一些更改和很少的构建后,我意识到他们不再显示了。我真的不记得我做了什么改变。

使用Samsung Duos 4.1.2时我可以选择[但不在操作栏中],它们来自设备本身的菜单按钮

我在Nexus和Samsung设备上都需要这些选项。

对于我已经处理过的事情 -
- showAction =“always”
- 我的班级正在扩展“活动”
- 不使用v7中的工具栏小部件,使用XML - 主题兼容性[不确定]

1 个答案:

答案 0 :(得分:0)

试试。在活动

中的 onCreate()中调用此方法
private void setOverflowIcon(){
        try {
            ViewConfiguration config = ViewConfiguration.get(this);
            Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
            if(menuKeyField != null) {
                menuKeyField.setAccessible(true);
                menuKeyField.setBoolean(config, false);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
相关问题