Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android listview lazy loading

I want to do some stuff. I wanna do lazy loading in ListView. My ListView contain more than 10,000 data & only in TextView. so i can't load all that data in first time when i launch list activity. it's not efficient so i can load first 20 or 30 items in list. further the rows of the ListView are loaded when I scroll over them. so when i reach at last index of ListView on last index, i will put progressbar n it will note that the new data are loaded, so at that time new data will be load with last + 1 index. How can i do this?

like image 486
Jai Avatar asked May 22 '12 06:05

Jai


Video Answer


1 Answers

You can achieve this by using endless Adapter implementation. This exactly does what you want. You can also restrict the number of rows to be refreshed per scroll. Here is a link to it.,

Android: Implementing progressbar and "loading..." for Endless List like Android Market

https://github.com/commonsguy/cwac-endless

To use it, you extend EndlessAdapter to provide details about how to handle the endlessness. Specifically, you need to be able to provide a row View, independent from any of the rows in your actual adapter, that will serve as a placeholder while you, in another method, load in the actual data to your main adapter. Then, with a little help from you, it seamlessly transitions in the new data.

like image 90
Andro Selva Avatar answered Sep 20 '22 18:09

Andro Selva