This is a bit complicated, but here is a general idea:
public void showPopup(View v) { PopupMenu popup = new PopupMenu(this, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.layout.menu, popup.getMenu()); popup.show();
}
In this method, v displays the view that you want your menu to display.
You will need the Override menu button so that when the user clicks, your menu appears. Do the following
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ( keyCode == KeyEvent.KEYCODE_MENU ) {
And then everything else will be the same as for your regular menu (I think)
source share