RadioButton in menu

How can I achieve something like a radio-button in my menu? Something like the CheckBoxMenu but that only allows exactly 1 selected item.

  • What you're trying to do sounds like a list as far as regular app settings.  For on device, I do this:

    Where each time onSelect is called in the menu delegate, I change the subLabel.

    Menu2.addItem(new WatchUi.MenuItem("Background Color",colorNames[MySettings.backgroundIdx],"bg",{}));

    Then in the delegate:

    if(id.equals("bg")) {
        MySettings.backgroundIdx=(MySettings.backgroundIdx+1)%14;
      	item.setSubLabel(colorNames[MySettings.backgroundIdx]);
      	MySettings.writeKey(MySettings.backgroundKey,MySettings.backgroundIdx);
    	MySettings.background=MySettings.getColor(null,null,null,MySettings.backgroundIdx);
    }

    If you want to see how this all works on a device, download my Simple Lean G2 WF: https://apps.garmin.com/en-US/apps/c051f37a-8fad-4907-b124-0112fe010c91

  • I can't think of a scenario where a radio button makes sense. Normally, I'd expect to have a menu item that gave a list of options, similar to what has been suggested by .

    If you really want to do something like a radio button, you can do that with a Menu2. The Menu2 class just keeps a reference to each of the items that were added. When one item is selected, you would iterate the other items and deselect them.

  • I thought this is so trivial requirement (being able to select exactly 1 item from a list) that I was surprised it's not built-in. Your way of doing it involves too much hassle compared to how simple this should be.

    's solution works, but it's not very intuitive IMHO for the user: 1. I can only see the currently set value and not the other possible values, 2. I'm not sure everyone understands what button needs to be clicked and what happens.

  • It's actually similar to other menu fields even in native apps, where pressing select toggles menu items, etc.