简体   繁体   English

自定义ActionBar和溢出菜单

[英]Custom ActionBar and overflow menu

I am implementing custom ActionBar, how should I handle the overflow menu (3 dots icon on the right here: http://developer.android.com/images/ui/actionbar.png )? 我正在实现自定义ActionBar,如何处理溢出菜单(此处右侧的3点图标: http : //developer.android.com/images/ui/actionbar.png )? The overflow menu should be visible if there is no hardware menu button - but how can I detect that? 如果没有硬件菜单按钮,则溢出菜单应该可见-但是如何检测到?

I'm not using the system ActionBar, because I need a customized behavior. 我没有使用系统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();

}

} }

The menu button is somewhat outdated , maybe you want to reconsider and stick to the overflow menu? 菜单按钮有些过时 ,也许您想重新考虑并坚持使用溢出菜单? And by the way, do you know http://actionbarsherlock.com/ ? 顺便说一句,您知道http://actionbarsherlock.com/吗?

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

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