在安卓2.3姜饼创建弹出菜单姜饼、弹出、菜单

2023-09-07 08:35:45 作者:可以挥霍的时间叫青春№

我在android的中级程序员。现在,我开发一个应用程序,它有一个视图。当我点击这个观点我要显示弹出菜单。

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.

我从Android开发者网站上的以下code

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();
}

但是,这code仅工作在API 11以上。

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?

推荐答案

您可以使用PopupWindow和showAsDropDown()来代替。

you can use PopupWindow and showAsDropDown() instead.

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