Disable autoscroll top on insertRowBefore in a TableView in Appcelerator/Titanium

梦想的初衷 提交于 2019-12-25 02:26:36

问题


i'm currently using a TableView to display some elements in Appcelerator/Titanium. The problem that i have is that when i make a pull to refresh and i call the method "insertRowBefore" to insert new elements at the beginning of the table using the method like following:

$.table.insertRowBefore(0,row); 

The table auto scrolls to top, and it looks a little bit bad when there're a lot rows to insert, i want to keep the current position. Any ideas?


回答1:


I have had the same problem it looks very ugly when inserting rows at table's top. I have managed this strange behavior by not inserting rows in table directly but inserting them to an array first :

//i suppose that you have an initial array contain your old rows oldRows
//add rows in the top 
for(int i=0;i<7;i++)
    oldRows.unshift(newRows[i]);

then set table's data

$.table.setData(oldRows);


来源:https://stackoverflow.com/questions/24500321/disable-autoscroll-top-on-insertrowbefore-in-a-tableview-in-appcelerator-titaniu

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