Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating popup menu in android 2.3 GingerBread

I am an intermediate level programmer in android. Now I am developing an app which has a view. When I click that view I have to display a popup menu.

I got the following code from android developer site

public void showPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.actions, popup.getMenu());
    popup.show();
}

But this code is working only on API 11 and above.

Can anyone help me so that I can make a popup menu that supports also GingerBread?

like image 930
Sam Avatar asked Oct 04 '22 05:10

Sam


1 Answers

you can use PopupWindow and showAsDropDown() instead.

OR http://developer.android.com/guide/topics/ui/menus.html#FloatingContextMenu

like image 144
Madthew Avatar answered Oct 10 '22 01:10

Madthew