How can you implement such a FloatingActionButton in a Fragment so that when you click on it, the context menu pops up in the same position as the button.
1 answer
In the PopupMenu constructors, the second parameter is the view, next to which the menu should be displayed. Try this:
@Override public void onClick(View view) { popupMenu = new PopupMenu(MainActivity.this, view); // TODO setOnDismissListener(), setOnMenuItemClickListener() popupMenu.inflate(R.menu.popup_menu); popupMenu.show(); } |
