LarsWerkman / QuickReturnListView

A implementation of Roman Nurik's and Nick Butcher's Quick Return UI patern for a listview.
Apache License 2.0
698 stars 187 forks source link

ListView rendering the whole set of rows #5

Open AhmadTK opened 11 years ago

AhmadTK commented 11 years ago

I came to a situation with the QuickReturnListView where I noticed that the ListViewadapter is loading the whole set of rows, for example I have ListView with 21 rows, I have traced getView method on the baseAdapter and I found it's loading the whole 21 rows sequentially where the ListView should only load the visible item.

I have tried to remove "getComputedScrollY" method from "QuickReturnListView" class and the ListViewis no longer loading the whole set.

Thanks.

egfconnor commented 10 years ago

This is working as expected as the computeScrollY literally gets the view from getView and then calculates the height for each view among other things. It should only happen once during onGlobalLayout though.

robertogds commented 10 years ago

If you know that all your items have the same height, then you should change the computeScrollY() method and only measure the height of one of them (before the for loop) and inside the for just add the calculated height to all items. It improves the performance drastically. Be careful if you have a header or footer.