Android的列表视图延迟加载 [英] Android listview lazy loading

查看:174
本文介绍了Android的列表视图延迟加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做一些东西。我想要做延迟加载在的ListView 。我的的ListView 包含超过10,000个数据和放大器;只有在的TextView 。这样我就可以不加载所有的数据在第一次当我启动列表中的活动。它的效率不高,所以我可以首先加载20个或30个项目的清单。进一步的ListView 的行,当我通过滚动它们的加载。所以,当我达到的ListView 去年指数的最后一个索引时,我都会把进度ñ它会注意到,加载了新的数据,所以当时的新数据将被加载与去年+ 1的索引。我怎样才能做到这一点?

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?

推荐答案

您可以用无穷的适配器实现实现这一目标。这正是你想要做什么。还可以限制每个滚动被刷新的行数。这里是一个链接到它。

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这样的市场的实施不尽的名单

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

要使用它,您将扩展EndlessAdapter提供关于如何处理的无穷无尽的细节。具体来说,您需要能够提供一排景观,独立于任何实际适配器行,将作为一个占位符,而你,在另一种方法,负载的实际数据到主适配器。然后,从你的一点帮助,它的无缝切换,在新的数据。

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.

这篇关于Android的列表视图延迟加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆