什么是构建的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
模式
使用延迟加载,如果你有大量的数据来填充列表
使用光标
从光标,如果你的数据来自数据库
建立基础数据,而不是对象列表,你救内存没有创造额外的对象。
看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 from database
, 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