问题描述
在我的应用我已经作出了自己的动作条,以及它工作得很好。
In my application I have made my own Actionbar, and it works very well.
不过,我喜欢用的ICS-设备溢出按钮的行为,没有菜单按钮。
I would however like to use the behaviour of the overflow buttons on ICS-devices with no menu-button.
有没有办法来实现在ICS定制Overflowbutton是分开的动作条?
Is there a way to implement a custom Overflowbutton in ICS that is separate from the Actionbar?
谢谢!
推荐答案
userSeven7s大多与 ListPopupWindow
,但更好的贴合在这种情况下是<$c$c>PopupMenu$c$c>,它允许你吹一个标准的 menu.xml文件
。你可以把自己的查看
或按钮
在右上角和的onClick
处理程序创建并显示一个弹出菜单。
userSeven7s mostly has it with the ListPopupWindow
, but an even better fit in this case is the PopupMenu
, which allows you to inflate a standard menu.xml
. You can place your own View
or Button
in the upper right and in the onClick
handler create and show a PopupMenu.
这是例子可以在ApiDemos>视图>弹出菜单中找到。特别是<$c$c>PopupMenu1.java$c$c>:
An example can be found in ApiDemos > Views > Popup Menu . Specifically PopupMenu1.java
:
public void onPopupButtonClick(View button) {
PopupMenu popup = new PopupMenu(this, button);
popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(PopupMenu1.this, "Clicked popup menu item " + item.getTitle(),
Toast.LENGTH_SHORT).show();
return true;
}
});
popup.show();
}
这篇关于Android的定制溢出菜单(无动作条和菜单按钮没有)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!