The Menu2Sample doesn't specify the menus in xml files. How can I show a Menu2 from an xml file and load it in the Mainlayout?
The resource documentation says nothing about menus.
The Menu2Sample doesn't specify the menus in xml files. How can I show a Menu2 from an xml file and load it in the Mainlayout?
The resource documentation says nothing about menus.
/* Replace this code and use XML menu resource instead */
var menu = new WatchUi.Menu2({:title=>"My Menu2"});
menu.addItem(
new MenuItem(
"Item 1 Label",
"Item 1 subLabel",
"itemOneId",
{}
)
);
menu.addItem(
new MenuItem(
"Item 2 Label",
"Item 2 subLabel",
"itemTwoId",
{}
)
);
WatchUi.pushView(menu, null, WatchUi.SLIDE_IMMEDIATE);
How can I replace this code by loading an xml menu2 file?
Oh, you're talking about defining a Menu2 in xml, and not using it in another layout.
I'm not sure, as I generally define a menu in the code so it can be more dynamic, based on the state of the app, setting the text ,toggles, etc.
The resource documentation says nothing about menus.
You're looking at the wrong section. Have a look here:
https://developer.garmin.com/connect-iq/programmers-guide/user-interface#menu2xmlresources
Just figured it out by taking a look at the "MenuTest" example project and not the "Menu2Sample".
What I couldn't figure out is that I can create the Instance of the menu by accessing "Rez.Menus.Menuname" and it is not mentioned anywhere in the documentation. Unfortunately Eclipse didn't show the auto complete option (only after restarting the editor).
WatchUi.pushView(new Rez.Menus.StartSelectionMenu(), null, WatchUi.SLIDE_IMMEDIATE);
that link is broken, but here's something that works with minor examples: developer.garmin.com/.../