In a menu XML layout, there are three valid elements: <menu>, <group> and <item>. The item and group elements must be children of a menu, but item elements may also be the children of a group, and another menu element may be the child of an item (to create a Submenu). Of course, the root node of any file must be a menu element.
On Mar 30, 7:14 pm, suzannea <suzanne.alexan...@gmail.com> wrote: > Does anyone have an example of adding a submenu to an options menu in > XML? I'm interested in doing something like this Java example (from > the Google developer guide, Creating Menus): > > public boolean onCreateOptionsMenu(Menu menu) { > boolean result = super.onCreateOptionsMenu(menu); > > SubMenu fileMenu = menu.addSubMenu("File"); > SubMenu editMenu = menu.addSubMenu("Edit"); > fileMenu.add("new"); > fileMenu.add("open"); > fileMenu.add("save"); > editMenu.add("undo"); > editMenu.add("redo"); > > return result; > > } > > However, I designed my options menu in XML, using the visual layout > editor. I tried putting several items within a group, like this: > > <group android:enabled="true" android:visible="true" > android:menuCategory="container" android:id="@+id/update_group"> > <item android:title="Facebook" android:id="@+id/facebook"></item> > <item android:title="MySpace" android:id="@+id/myspace"></item> > </group> > > But instead of getting a submenu, I got additional items on the > options menu, which created an extended menu. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---