在机器人高效的ListView [英] Efficient ListView in android
本文介绍了在机器人高效的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是构建的ListView
,使用最少的内存可能的最佳方式?这一点很重要,因为我遇到了一些实现,大部分的时候我滚动的ListView
在低端设备落后,但我看到一些应用程序,其中滚动非常流畅,即使在低端设备。怎样才能做到呢?什么是从一个内存使用点的最有效的方式来构建这样一个的ListView
?
What is the best way of constructing a ListView
that uses the least memory possible? This is important, because I met a few implementations and most of them is lagging when I scroll the ListView
on low-end devices, but I saw a few apps, where the scroll is very smooth, even on low-end devices. How can it be done? What is the most efficient way from a memory usage point of view to construct such a ListView
?
推荐答案
- 回收的
getView你的意见()
- 使用
ViewHolder
模式 - 使用延迟加载,如果你有大量的数据来填充列表
- 使用
光标
从光标,如果你的数据来自数据库
建立基础数据,而不是对象列表,你救内存没有创造额外的对象。 - 看<一href="http://www.google.com/events/io/2010/sessions/world-of-listview-android.html">http://www.google.com/events/io/2010/sessions/world-of-listview-android.html
- 在看到 http://android.amberfog.com/?p=296
- recycle your views in
getView()
- use
ViewHolder
pattern - use lazy loading if you have a lot of data to fill the list with
- use
Cursor
as underlying data instead of object list built from cursor if your data comes fromdatabase
, you save memory by not creating additional objects. - see http://www.google.com/events/io/2010/sessions/world-of-listview-android.html
- see http://android.amberfog.com/?p=296
这篇关于在机器人高效的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文