Gallery ImageAdapter convertView is always null

前端 未结 3 1217
囚心锁ツ
囚心锁ツ 2021-02-02 15:57

I am using a Gallery with an ImageAdapter to load it with ImageViews that pull images out of my resources. My problem is that the convertView that gets passed to the getView() m

3条回答
  •  无人共我
    2021-02-02 16:42

    I've gotten around this by using a custom cache as dskinner suggests.

    I pre-calculate (screenwidth/minwidth of item) the max # of items that can be show in the gallery on the screen at one time and add a few more (the gallery will need extra to show items on the left and right as you scroll thru it). I create an array of this size - the views get created as requested and placed in the cache. Use position % cachesize to figure out which cached view to return when getView is called.

提交回复
热议问题