To return android menu.xml to list

Asked 2 years ago, Updated 2 years ago, 22 views

Can I parse the menu.xml file and return it to the list?

android

2022-09-21 15:19

1 Answers

...

PopupMenu p  = new PopupMenu(this, null);
Menu menu = p.getMenu();
getMenuInflater().inflate(R.menu.some_menu, menu);

//Usage of menu
System.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());

...

https://stackoverflow.com/questions/8750562/parsing-android-menu-xml-resource-to-objects-list


2022-09-21 15:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.