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
3 Answers
-
Accepted Answer
It's been raised here for a future release.
-
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. -
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?