Ti.UI.Picker.setSelectedRow() not working
I just started using Appcelerator these last few days. I am trying to add a Picker object to the page, populated with two columns of data. I would like to have default (aka pre-selected) rows for each column, and tried to do this like so:
picker.setSelectedRow(0,3);
picker.setSelectedRow(1,2);
I also tried setting the selected:
attribute directly while creating the PickerRow
objects. However, neither method is working. I've tried the setSelectedRow()
method both before and after adding it to the window. Any ideas?
Thanks for the help!
2 Answers
-
Accepted Answer
This seems to be a known bug. I recently ran into it with my project, and had to move setSelected() into the 'open' event of the current window, like so:
Ti.UI.currentWindow.addEventListener('open', function() { picker.setSelectedRow(0, 2, true); });
You can also see this ticket:
https://appcelerator.lighthouseapp.com/projects/32238/tickets/1282-picker-setselectedrow-os-4-sdk-133-head -
How I can keep it closed??? before setSelectedRow ??