Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add item to ListView without reloading

I'm wondering if there's a way to add an item to the ListView without causing the reload of the whole list.

I have a BaseAdapter-derived ListView adapter, and when the underlying model gets a new element added, it calls notifyDataSetChanged(), which triggers the ListView reload.

The elements in the list have images, which are dynamically loaded according to the element's content. Problem is, when getView() is called during the reload, the convertView parameter passed for reuse is from a different position previously, so the images have to be reloaded, too, which causes a rather ugly blinking.

So is there a way to not reload the whole list if I only add an item at the end (and that will be the only way new items are added)? Or at least somehow reuse the cells for the same position, if possible, to avoid the costly image reload?

like image 300
SVD Avatar asked Nov 23 '11 04:11

SVD


1 Answers

No buddy its not possible in android that u can add an item without refresh the list because when u add an item it changes the height of list view.See the below link,Romain Guy said the same thing in it.

http://groups.google.com/group/android-developers/browse_thread/thread/7e54522c37772d04/05abfd17b59b07f7?lnk=gst&q=how+to+add+list+item+in+listview+without+reload+the+listview+#05abfd17b59b07f7

like image 65
himanshu Avatar answered Oct 31 '22 01:10

himanshu