繁体   English   中英

自定义ActionBar和溢出菜单

[英]Custom ActionBar and overflow menu

我正在实现自定义ActionBar,如何处理溢出菜单(此处右侧的3点图标: http : //developer.android.com/images/ui/actionbar.png )? 如果没有硬件菜单按钮,则溢出菜单应该可见-但是如何检测到?

我没有使用系统ActionBar,因为我需要自定义行为。

ViewConfiguration.get(context).hasPermanentMenuKey()
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();

}

}

菜单按钮有些过时 ,也许您想重新考虑并坚持使用溢出菜单? 顺便说一句,您知道http://actionbarsherlock.com/吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM