创造最好的方法下拉菜单中的Andr​​oid 2.X像ICS最好的、方法、菜单中、Andr

2023-09-12 21:45:54 作者:别离趁早

我要创建按钮与动作条中的下拉菜单,像溢出菜单按钮ICS。我有问题,因为PopupMenu的没有在安卓2.x的使用微调第二种方式,但它并不适合我,因为微调始终显示在我的自定义背景,或我选择的项目的第一个项目。我怎样才能acheive呢?在一般情况下,我想文本菜单,但很少和位置点击查看。谢谢你。

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 :

推荐答案

如果你的目的是重新创建一个动作吧,你可以看看在 ActionBarSherlock 项目,该项目backports中放入系统的功能。

If your purpose is to recreate an action bar, you could take a look at the ActionBarSherlock project, which backports thoses functionalities.

如果您希望能够在任何地方弹出这样的菜单在您的应用程序,你可以阅读的MenuPopupHelper类实现在 ActionBarSherlock 项目源$ C ​​$ C。

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.