Android listview 懒加载 [英] Android listview lazy loading
问题描述
我想做点事.我想在 ListView
中进行延迟加载.我的 ListView
包含超过 10,000 个数据 &仅在 TextView
中.所以当我启动列表活动时,我无法在第一时间加载所有数据.它效率不高,所以我可以加载列表中的前 20 或 30 个项目.当我滚动它们时,会进一步加载 ListView
的行.因此,当我到达最后一个索引上 ListView
的最后一个索引时,我会将进度条 n 放在它会注意到新数据已加载的位置,因此届时将使用 last + 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:实现进度条和加载...";适用于 Android Market 之类的 Endless List
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 listview 懒加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!