Multiple calling of getView() in GridView

后端 未结 3 498
陌清茗
陌清茗 2021-02-02 17:34

My Activity consists of GridView which holds 40+ elements. After starting activity user could see maximum 15 items (3 rows, 5 items in each row). I wrote in getView() body to pa

3条回答
  •  遥遥无期
    2021-02-02 18:07

    For me, it's even worse: 0 position is called often 10 times. And it's called even if I'm at the end of the list, without position 0 on the screen.

    My solution is a static ArrayList of items being currently processed for display and I ignore those double-calls. It's not the best solution though as it still uses resources to get 0 position while it's even not on the screen.

    As it seems like a bug, I think I will cache a View for position 0 so it would get a quick and proper return value even if the position is not on the screen.

    Android 4.2.2.

提交回复
热议问题