Android PopupMenu显示

private void showPopupMenu(View view) {

    PopupMenu popupMenu = new PopupMenu(context, view);
    popupMenu.getMenuInflater().inflate(R.menu.teacher_cat_select_menu, popupMenu.getMenu());
    popupMenu.show();
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        [@Override](https://my.oschina.net/u/1162528)
        public boolean onMenuItemClick(MenuItem menuItem) {

            popupMenu.dismiss();

            return true;
        }
    });

    popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
        [@Override](https://my.oschina.net/u/1162528)
        public void onDismiss(PopupMenu popupMenu) {

            return;

        }
    });

}

转载于:https://my.oschina.net/leegq/blog/3084788

你可能感兴趣的:(Android PopupMenu显示)