我正在实现自定义ActionBar,我应该如何处理溢出菜单(3点图标在这里:http://developer.android.com/images/ui/actionbar.png)?如果没有硬件菜单按钮,溢出菜单应该是可见的 - 但我怎么能检测到?自定义ActionBar和溢出菜单
我没有使用系统的ActionBar,因为我需要一个自定义的行为。
我正在实现自定义ActionBar,我应该如何处理溢出菜单(3点图标在这里:http://developer.android.com/images/ui/actionbar.png)?如果没有硬件菜单按钮,溢出菜单应该是可见的 - 但我怎么能检测到?自定义ActionBar和溢出菜单
我没有使用系统的ActionBar,因为我需要一个自定义的行为。
ViewConfiguration.get(context).hasPermanentMenuKey()
菜单按钮是somewhat outdated,也许你想重新考虑并坚持溢出菜单?顺便说一下,你知道吗http://actionbarsherlock.com/?
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();
}
}
在onCreate方法中使用此代码。 – 2014-08-21 10:09:02
Android 4.0的动作条隐藏在其上具有HW菜单按钮的设备的溢出菜单。我想模仿这种行为。我不能使用系统的ActionBar或ActionBarSherlock,因为我需要一个非常特殊的行为,这是ABS不可能实现的。 – fhucho 2012-02-27 21:19:49
好吧,只是认为你可以分叉ABS并在其上实现你的特定行为。你有没有检查Android的源代码? – 2012-02-27 21:25:22
不,但我会尝试:)分叉ABS看起来像很多工作... – fhucho 2012-02-28 11:49:33