Android Work with PopupMenu

PopupMenu popup = new PopupMenu(context, button);
                popup.inflate(R.menu.weight_table_menu);
                //popup.setGravity(Gravity.END);

                popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        switch (item.getItemId()) {
                            case R.id.menuItemDelete:

                                //

                                historyList.remove(viewHolder.getAdapterPosition());
                                notifyItemRemoved(viewHolder.getAdapterPosition());
                                return true;

                            case R.id.menuItemEdit:

                                //

                                return true;
                        }
                        return false;
                    }
                });

                popup.show();