Titanium picker scrolling lags for the first time

℡╲_俬逩灬. 提交于 2019-12-11 13:02:41

问题


I am a newbie to Titanium. I am creating a picker in Titanium which loads a set of records from my local sqlite database.

Whenever I scroll the picker, for the first time there seems to be a small lag in scrolling. That is, when user scrolls the picker, there is a lag for few seconds and then users are allowed to scroll records continuously. This lags happens only for the first time.

Can anyone please guide me how to fix this scroll lag.

My code is as follows:

    function CREATEPICKER(rows, x, y, width, sel, initialValue) {
    var picker = Ti.UI.createPicker({left: x, height: Ti.App.pickerHeight, top: y, plat: '', width : width});
    var data =[];
    var v, selectedrow;
    data[0]=Ti.UI.createPickerRow({title: initialValue, font:{fontSize: 48} });
    var j = 1;
    while (rows.isValidRow())
    {
        v = rows.fieldByName('id');     
        if((v != null) && (v != '') && (v != 'NULL')) {
            if(v == sel) selectedrow = j;
            data[j]=Ti.UI.createPickerRow({title: v, fontSize: 48 });
            j++;
        }
        rows.next();
    }
    if(selectedrow > 0) picker.setSelectedRow(0,selectedrow);
    picker.selectionIndicator = true;
    picker.add(data);
    return(picker);
}

Can someone please guide me.

Thank You.


回答1:


Try doing this, when adding items to your data array:

data[j] = Ti.UI.createPickerRow( {
   title : j++,
   font : {
      fontSize : 48
   }
} );


来源:https://stackoverflow.com/questions/21330763/titanium-picker-scrolling-lags-for-the-first-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!