Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update ListView on scrolling while retrieving data from server in Android?

Currently, I'm using AsyncTask to handle Http connection and retrieve data as JSON format.
Loading all data is trivial but it consumes too much time, so I decided to switch to load 10 items at a time using LIMIT OFFSET (mysql).
Next I set up the event onScroll for my list view to create a new AsyncTask each time user scroll. However, from what I read, AsyncTask is stored in a thread pool which is limited 5 threads at a time, so I'm not sure this is a right approach. I'm newbie to client/server app, so could I anyone give me an advice on this issue? Any related article, documentation would be greatly appreciated.

like image 720
Cathy Avatar asked Jan 19 '12 04:01

Cathy


1 Answers

Here are few useful links for it,

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

Endless Listview with current Async Task

Android Endless List

http://www.androidguys.com/2009/10/21/tutorial-autogrowing-listview/

http://mylifewithandroid.blogspot.com/2010/03/progressively-loading-listviews.html

In simple steps,

As user scrolls – detect the end of the list
1)Display a progress notification
2)Ask for update
3)Receive update (asynchronously) and extend list

like image 105
Andro Selva Avatar answered Oct 21 '22 14:10

Andro Selva