Stack Overflow archive
14 score

PopupMenu Icon doesn't show

score
14
question views
6K
license
CC BY-SA 3.0

The MenuBuilder is a hidden class but does contain a method to show icons. You will need to use reflection to show the icons in the menu. Try adding this in showPopop(View, int):

java
PopupMenu popup = new PopupMenu(mContext, v);
try {
  Method method = popup.getMenu().getClass().getDeclaredMethod("setOptionalIconsVisible", boolean.class);
  method.setAccessible(true);
  method.invoke(popup.getMenu(), true);
} catch (Exception e) {
  e.printStackTrace();
}

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.