android中的高效ListView [英] Efficient ListView in android

查看:28
本文介绍了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 模式
  • 如果你有很多数据来填充列表,请使用延迟加载
  • 如果您的数据来自database,则使用Cursor 作为基础数据而不是从光标构建的对象列表,您可以通过不创建其他对象来节省内存.
  • 参见 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
    • 这篇关于android中的高效ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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