Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Dynamically load Listview at scroll end?

Tags:

android

I am loading a listview from Http server, 20 at a time ,At the end of Listview I a want to load next 20 data from server and this process will continue till data ends in server ,I used class that extend BaseAdapter to populate first 20 data .what should i do??

like image 761
augustine Avatar asked Feb 21 '11 11:02

augustine


3 Answers

This looks to be an elegant solution as well: http://benjii.me/2010/08/endless-scrolling-listview-in-android/

It also implements an AbsListView.OnScrollListener, and uses an AsyncTask to load more content as soon as a certain threshold of remaining items in the current scroll view is reached.

like image 61
ramz Avatar answered Oct 02 '22 05:10

ramz


Ok i have seen that this is a common problem, so i have made a SMALL LIBRARY with custom load more and pull to refresh ListView in github, please check this at here, all is very explained in the repository.

like image 41
shontauro Avatar answered Oct 02 '22 05:10

shontauro


You can implement an AbsListView.OnScrollListener, that gets informed and which allows you to load more data.

See e.g.

....
ListView.setOnScrollListener(this);
....

And then have a look at https://github.com/pilhuhn/ZwitscherA/blob/master/src/de/bsd/zwitscher/TweetListActivity.java#L287

Or take a look at the List9 example from the sdk examples.

like image 26
Heiko Rupp Avatar answered Oct 02 '22 06:10

Heiko Rupp