我在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