Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid re-drawing all views in an ArrayAdapter

I have an ArrayAdapter powering a ListView. I would like to change the data behind the ArrayAdapter and update the ListView's. Sounds like notifyDataSetChanged(); would be exactly what I am looking for, but it updates the entire ListView, and I would prefer to update on a row-by-row basis.

Is there a way to do this with ArrayAdapter, or do I need to manage my data some other way if I want this functionality?

like image 473
Hamy Avatar asked Nov 22 '25 05:11

Hamy


1 Answers

It doesn't work like that, as far as I know.

It will only redraw the visible rows. This happens when you're scrolling anyway. If you're scrolling down, and one of your rows (a View) goes off the top, Android reuses it if possible when drawing rows that come into view from the bottom. This is what the 3rd parameter (convertView) of ListAdapter.getView() is for.

I'm pretty sure Android only draws the rows that you're able to see in any case.

like image 142
synic Avatar answered Nov 23 '25 19:11

synic