Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient ListView in android

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?

like image 888
overbet13 Avatar asked Jan 15 '23 23:01

overbet13


1 Answers

  • 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
like image 66
biegleux Avatar answered Jan 28 '23 07:01

biegleux