I created a popup menu. I need to hide a particular item from popup menu on condition, I tried this below code but it doesn\'t work and shows \"unexpectedly your app has
This answer may be helpful to someone,
I used below
popupMenu.getMenu().findItem(R.id.next).setVisible(true);
If you want to change the text of the menu, you can use below code,
popupMenu.getMenu().findItem(R.id.next).setTitle("After");
You need to get the Menu
Object from the PopupMenu before you get the item. So it'd be something like
Menu popupMenu = popup.getMenu();
if(Global.lock == true)
popupMenu.findItem(R.id.lock_message).setEnabled(false);
else
popupMenu.findItem(R.id.unlock_message).setEnabled(false);
And I'd do this before you call popup.show()