SDK 2.1.3.GA, targeting Android 2.3.3 onwards
I'm having problems with the following bit of code. It's setting up the columns for an 'hours, minutes, seconds' picker, and it works perfectly, but the performance is really terrible. It all comes down to the "pickerColumns.push..." line. That line alone takes 3 seconds to create a column with 60 rows, giving a delay of about 8 seconds for the screen to respond - this is on a Nexus (i9250)
I'm also see lines (for every picker row, i.e. 144 lines) in the console saying ".... Nativeview is null". This is appearing after this section of code has completed.
var pickerColumns = []; for (var i = 0; i < data.length; i++) { var pickerRows = []; for (var j = 0; j < data[i].length; j++) { pickerRows.push(Ti.UI.createPickerRow({ title : data[i][j] })); } pickerColumns.push(Ti.UI.createPickerColumn({ rows : pickerRows })); }Any clues why this is so slow? Is there a better way to achieve this?
Thanks for looking
2 Answers
the 'rows' property is marked as read-only for a PickerColumn
the problem should come from here. use addRow() instead
rows : Titanium.UI.PickerRow[] READONLY
While this property is currently writable on Android, changing its value is strongly discouraged.
After further investigation it appears that this problem had precious little to do with the code, and everything to do with where the code was being executed. I was trying to create the picker on a window 'open' event. If I move the code to a 'click' event, for example on a button, then the performance is perfectly acceptable - i.e. milliseconds, rather than seconds.
If anyone knows why this is the case please tell me!
Your Answer
Think you can help? Login to answer this question!