Skip to content

Instantly share code, notes, and snippets.

@luck-alex13
Created February 19, 2018 07:14
Show Gist options
  • Save luck-alex13/e9173c21612c8d26acc7ba40af1d1555 to your computer and use it in GitHub Desktop.
Save luck-alex13/e9173c21612c8d26acc7ba40af1d1555 to your computer and use it in GitHub Desktop.
Show Android Popup Menu
public static PopupMenu buildPopupMenu(View view, int menuRes) {
PopupMenu popup = new PopupMenu(view.getContext(), view);
popup.inflate(menuRes);
return popup;
}
public static PopupMenu showPopupMenuOn(View view, int menuRes, PopupMenu.OnMenuItemClickListener listener){
PopupMenu menu = buildPopupMenu(view, menuRes);
menu.setOnMenuItemClickListener(listener);
menu.show();
return menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment