Toggle Menu Item

I have a Fenix3 and if I go to the main setting and select Bluetooth, the Status menu item has a graphical toggle switch. How can I code a similar menu item for an app?

Currently I can set up a menu and when an item is selected this goes to another menu and the user can select yes/no options. The above toggle/graphical method is a lot more user friendly.

Thanks,
  • Former Member
    Former Member over 9 years ago
    The native menus that can be used directly from ConnectIQ do not support this behavior. To replicate this, you would need to build a custom menu from the default View object.
  • Cheers Brian,
    Was thinking it was going to be something like that.

    Another option I was thinking of was to change the text string within a menu. To get a string you use

    Ui.loadResource(Rez.Strings.myString)

    but is there away to set a string like,

    setResource(Rez.Strings.myString, "New String")

    as I cant find one.

    Thanks,
    Hannes
  • Former Member
    Former Member over 9 years ago
    No, a resource is a static value that gets loaded from disk, so they cannot be written to.

    It also isn't possible to dynamically update the strings in the native menus. The strings are copied to a internal structure and sent to the native menu view. If you want a string to update you would have to pop the menu and push a new one with the updated string.
  • Former Member
    Former Member over 9 years ago
    Actually, it's completely possible to change the text that appears in menu items that are defined with menu resources: make the menu-item text reference a string resource (e.g. @Strings.some_str) and modify the value of that resource (e.g.: Rez.Strings.some_str = "New text"). You have to re-build the menu object each time you pushView it to pick up the changed values, but this works great for me.

    Example app that uses this: ZuluTime widget