如何在同时从服务器在Android中检索数据滚动更新的ListView? [英] How to update ListView on scrolling while retrieving data from server in Android?
问题描述
目前,我使用的AsyncTask来处理HTTP连接和检索数据的JSON格式。结果
加载所有数据是微不足道的,但它消耗了太多的时间,所以我决定用切换 OFFSET LIMIT(MySQL的)一次装载10个项目。结果
接下来,我设置的事件 onScroll
我的列表视图中创建一个新的的AsyncTask
每次用户滚动。但是,从我读的AsyncTask
存储在一个线程池是在一个时间限制5个线程,所以我不知道这是一个正确的做法。我是新手到客户端/服务器应用程序,所以我可以给任何人我在这个问题上的建议吗?任何相关的文章,文件将大大AP preciated。
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.
推荐答案
这里有一些有用的链接它,
Here are few useful links for it,
<一个href=\"http://www.androidguys.com/2009/10/21/tutorial-autogrowing-listview/\">http://www.androidguys.com/2009/10/21/tutorial-autogrowing-listview/
<一个href=\"http://mylifewithandroid.blogspot.com/2010/03/progressively-loading-listviews.html\">http://mylifewithandroid.blogspot.com/2010/03/progressively-loading-listviews.html
在简单的步骤,
随着用户滚动 - 检测列表 - 1月底)显示进度
通知结果2)询问更新结果3)接收更新(异步)和
扩展列表
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
这篇关于如何在同时从服务器在Android中检索数据滚动更新的ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!