简体   繁体   中英

Android call getView on every element in ListView

I understand for efficiency, android only calls the getView method on certain elements in a ListView (those visible, or clicked on, etc.)

http://developer.android.com/reference/android/widget/ArrayAdapter.html#getView

For my custom ArrayAdapter implementation, however, it is important that getView be called for every element in the list (regardless of whether or not it is visible).

Is this possible to do?

What do you want to achieve? GetView is called with every item, is up to you to implement a ViewHolder or something like that in order to re-use the view or not. However, you should do.

I have some Bitmaps inside of the objects within my listview, which are loaded in getView, however I need them elsewhere on the screen too. The observed behaviour is they load on the screen (elsewhere) only when I scroll to them in the listview.

Simple solution would be to load your images elsewhere and as soon as you load them you can update your list adapter by calling notifyDataSetChanged() .

Note : You cannot invoke getView() for those list items which are not visible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM