Knowing when a View in a ListView has gone off the screen?

后端 未结 4 1060
醉梦人生
醉梦人生 2020-12-30 23:36

I have Googled this but can\'t find an answer, so here goes...

I have a ListView that displays some text and an image. The underlying adapter recycles the views for

4条回答
  •  一向
    一向 (楼主)
    2020-12-31 00:16

    If you use a LruCache for the bitmaps and have each view in the listview keep the key to the LruCache item, you can control it better.. Then, in getView, you first try and get the bitmap from the LruCache and only download it again if it is not there.

    Also, you can set an setOnScrollListener() on the ListView, and use its visibleItemCount parameter to adjust the size of the LruCache the first time the user scrolls.

提交回复
热议问题