Picker - Horizontal layout

Former Member
Former Member
I'm using the Picker in my app - FootballFixtures https://apps.garmin.com/en-US/apps/0835175d-0468-4c4b-a49b-8e2165f57677

The picker is displaying the text inside a narrow/vertical cell as showed on this image.


Is it possible to change the display for this picker to a horizontal/wider layout to prevent cropping of the text?
  • Have you looked at the picker sample program? Another option would be to use a menu, assuming that you don't have too many choices to display.
  • Former Member
    Former Member over 9 years ago
    1212

    Yes, I've studied the Picker sample code and could not find any settings related to a horizontal Picker layout. The menus could be an option, but I'm not sure how to add dynamic menu items (reading leagues and teams from web). I guess the count would be 20-30 items per menu, not sure if this could affect performance.
  • No, I never said there was a horizontal picker layout, and there isn't. I simply suggested looking at the picker sample because the top-level picker allows the user to pick strings. It seemed like a good place to start. I looked at the sample just now, and it has the same problem that you are running into. Each device has its own layout for the picker, and the draw area for the selected item is 48-60px wide on all of them (look at <SDKROOT>/bin/devices.xml), so you're just not going to be able to display long strings without some work.

    Honestly, I think you are trying to fit a square peg into a round hole. Although there are a few hooks you might be able to take advantage of (you have control of the title and can replace onUpdate to do whatever you want), I think that you could create your own view and delegate to do this pretty easily.

    Travis
  • I'm not sure how to add dynamic menu items

    This is pretty easy...

    const symbols = [
    :symbol0,
    :symbol1,
    :symbol2,
    :symbol3,
    :symbol4,
    :symbol5,
    :symbol6,
    :symbol7,
    :symbol8,
    :symbol9,
    :symbol10,
    :symbol11,
    :symbol12,
    :symbol13,
    :symbol14,
    :symbol15
    ];

    class MyMenuDelegate extends Ui.MenuInputDelegate
    {
    hidden var mTeams;

    function initialize(teams) {
    MenuInputDelegate.initialize();
    mTeams = teams;
    }

    function onMenuItem(item) {
    // figure out which item was selected
    for (var i = 0; i < symbols.size(); ++i) {
    if (symbols== item) {
    Sys.println(mTeams);
    break;
    }
    }
    }
    }

    class MyMenu extends Ui.Menu
    {
    function initialize(teams) {
    Menu.initialize();

    self.setTitle("Pick a team");

    for (var i = 0; i < teams.size(); ++i) {
    self.addItem(teams, symbols);
    }
    }
    }

    class MyInputDelegate extends Ui.BehaviorDelegate
    {
    function initialize() {
    BehaviorDelegate.initialize();
    }

    function onMenu() {
    var teams = [ "Patriots", "Seahawks", "Steelers" ];

    var menu = new MyMenu(teams);
    var delegate = new MyMenuDelegate(teams);

    Ui.pushView(menu, delegate, Ui.SLIDE_IMMEDIATE);

    return true;
    }
    }
    [/code]

    The issue is that you are limited to MAX_SIZE (16) items in any given menu. If you have more, then you need to figure out some way to divide the items up and then select the sub-items.

    Travis
  • I have an app that allows selection of an item from a list (I obtain that list over the internet, and it can vary in length but right now is 20+ items long). Here's what I do.

    The names are in an array, and I start with the index at 0. Then onUpdate() displays the name at that index. It's for a vivoactive, and I use touch regions for moving up and down the list. When I get a "down", I increment the index (with wrapping at the end), and the opposite for an "up". I then call requestUpdate(), and the new name is displayed. (this could be done with KEY_UP and KEY_DOWN for non-touch devices.

    When I want to act on that name, I use a different touch region, but again, something like KEY_ENTER/KEY_START could be used.

    Fairly simple to do, and no limit on the size of the list, other than available memory. It's basically just a simple scrollable list.
  • Yeah. Pretty much like I said in the post prior to showing how to do a dynamic list.
  • Former Member
    Former Member over 9 years ago
    TRAVIS.VITEK and PMjim_m_58 - Thanks for your comments and help. Yes, It seems that the best solution here is by using the built in menus or a custom scrollable list. Of course I was hoping for more help from the built in Picker functionality. I hope Garmin improve this in future updates to the SDK.