0

I need to modify the default ListView behavior so that when an item is deleted and the adapter has notifyDataSetChanged() called, instead of pulling the later items upward I want to pull the earlier items (including hidden ones the user has already scrolled past) downward. The ultimate goal is an infinite scrollable ListView that destroys the old views for memory conservation reasons and then keeps going. What I want to know is:

  1. How to modify this behavior, or...
  2. If ListView's design is already smart enough that if I use a library like Picasso or Universal Image Loader, or replace all hidden views with a dummy single color `Drawable, it can handle hundreds or thousands of scrolling items.

Thanks in advanced! For the endless scroll I hope to do something similar to here or here.

Community
  • 1
  • 1
pqn
  • 1,522
  • 3
  • 22
  • 33

1 Answers1

1

I would advise against fighting with ListView. The ListView is already highly optimized to conserve memory. It does not inflate a view for each item in the list, rather, it only inflates as many views as it needs to fill the screen and then recycles those views as the list scrolls. There is a very good Google I/O lecture from 2010 that explains how ListView works. You should watch this and rethink your approach.

Also you can use universal image loader with ListView. Many people have and there are a number of examples on this site. The most common pattern is the "lazy list" which you can read more about if you google it (or searc here). Basicly you only load things as you need them and destroy what you don't. This allows you to provide for long lists without using all your memory on hosting bitmaps and other content.

Rarw
  • 7,645
  • 3
  • 28
  • 46