Parsing Android menu XML resource to objects list
This will help:
...PopupMenu p = new PopupMenu(this, null);Menu menu = p.getMenu();getMenuInflater().inflate(R.menu.some_menu, menu);//Usage of menuSystem.out.println("LOG id: "+ menu.getItem(0).getItemId());System.out.println("LOG title: "+ menu.getItem(0).getTitle());System.out.println("LOG icon: "+ menu.getItem(0).getIcon());...
The creation of a PopupMenu its just a trick to create a Menu object that when inflated will be filled with the information defined on your xml.
Thanks Raul.It don't work for 2.33.I have found solution Here.
private Menu newMenuInstance(Context context) { try { Class<?> menuBuilderClass = Class.forName("com.android.internal.view.menu.MenuBuilder"); Constructor<?> constructor = menuBuilderClass.getDeclaredConstructor(Context.class); return (Menu) constructor.newInstance(context); } catch (Exception e){ MyLog.GetMyLog().e(e); } return null;}