问题描述
我想用下拉菜单创建按钮,就像ICS上的ActionBar中的溢出菜单按钮一样。我有问题,因为PopupMenu有没有在android 2.x.使用Spinner的第二种方式,但它不适合我,因为Spinner总是显示我的自定义背景或所选项目上的第一个项目。我怎么能看到它?一般来说,我想要ContextMenu,但是点击了点击视图。谢谢。
I want to create button with drop down menu, like overflow menu button in ActionBar on ICS. I have problem because PopupMenu there isn't in android 2.x. The second way using Spinner but it's not for me, because Spinner always show the first item on my custom background or my selected item. How can I acheive it? In general, I want ContextMenu but little and on position clicked view. Thanks.
看起来像这样:
It looks like this :
推荐答案
如果您的目的是重新创建一个动作栏,可以看看项目,该项目支持功能。
If your purpose is to recreate an action bar, you could take a look at the ActionBarSherlock project, which backports thoses functionalities.
如果您想要在应用程序的任何地方弹出这样的菜单,您可以阅读类实现在项目源代码。
If you want to be able to pop such a menu anywhere in your app, you could read the implementation of the MenuPopupHelper class implementation in the ActionBarSherlock project source code.
这篇关于在Android 2.x中创建下拉菜单的最佳方式就像在ICS中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!