Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Programmatically set options in an OptionDialog

Given the code below, how do I set a default option (selected when the dialog is opened)? Based on users' previous selections, it won't always be the first or last or whatever.

var units_dialog = Titanium.UI.createOptionDialog({
    options:['English', 'Metric'],
    title:'Units'
});

I tried things like default:0 or selected:0 and that didn't work.

Thanks,
Tim

— asked June 17th 2010 by Tim Poulsen
  • optiondialog
1 Comment
  • Well okay then, I guess you can't. So, what UI element do I use in its place? I need something for a preferences screen with multiple values for things like the units shown in my code sample. Something I can programmatically set (from saved preference info).

    — commented June 22nd 2010 by Tim Poulsen

3 Answers

  • Accepted Answer

    It's been raised here for a future release.

    — answered July 29th 2010 by Matt Collinge
    permalink
    0 Comments
  • Yes, I agree that this is an important feature. Does anyone know how to do it?
    If you look at some of the default Android apps, such as the alarm clock, they have this.

    — answered July 15th 2010 by Paul Dowsett
    permalink
    0 Comments
  • Now we have the version 1.9.* and there are a method setOptions(). But it doesnt work:

    var optionsDialogOpts = {
        options : ['CENTER TO ME', 'Start Monitor', 'Start Recording','Cancel'],
        cancel : 3,
        destructive : 1,
        title : 'Tides map:'
    };
    var dialog = Ti.UI.createOptionDialog(optionsDialogOpts);
    dialog.show();
    dialog.addEventListener('click', function(e) {
        switch(e.index) {
            case 0:
                // do something
            case 1:
                optionsDialogOpts.options[1] = 'Monitor beenden';
                dialog.setOptions(optionsDialogOpts);   
            break;  
        }
    });
    

    Why? Mistake of me?

    — answered April 2nd 2012 by Rainer Schleevoigt
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.