Android examples for User Interface:PopupMenu
display Icons In PopupMenu
//package com.java2s; import android.widget.PopupMenu; import java.lang.reflect.Field; import java.lang.reflect.Method; public class Main { public static void displayIconsInPopup(PopupMenu popup) { try {/*w w w.j a v a 2 s . co m*/ Field[] fields = popup.getClass().getDeclaredFields(); for (Field field : fields) { if ("mPopup".equals(field.getName())) { field.setAccessible(true); Object menuPopupHelper = field.get(popup); Class<?> classPopupHelper = Class .forName(menuPopupHelper.getClass().getName()); Method setForceIcons = classPopupHelper.getMethod( "setForceShowIcon", boolean.class); setForceIcons.invoke(menuPopupHelper, true); break; } } } catch (Exception e) { e.printStackTrace(); } } }