开发者

How to avoid re-drawing all views in an ArrayAdapter

开发者 https://www.devze.com 2022-12-24 06:02 出处:网络
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 f

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 upda开发者_开发百科tes 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号