Search code examples
androidandroid-actionbarandroid-4.0-ice-cream-sandwichdrop-down-menupopupmenu

The best way to create drop down menu in android 2.x like in ICS


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 : Overflow menu in right top corner


Solution

  • 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.