How can I dynamically add images to a GridView?

后端 未结 2 1298
无人及你
无人及你 2020-12-17 05:18

I have a GridView that is created based on an array of items. I need to add more images as the grid is scrolled to the bottom, but I\'m not sure how to do that.

2条回答
  •  自闭症患者
    2020-12-17 05:30

    You can get reference to the adapter backing the GridView by .getAdapter(). When the user scrolled down, get this adapter, add the new images (I think you should use an ArrayList instead of simple arrays so you can easily append more data in the ImageAdapter class), and call .notifyDatasetChanged() on the now modified adapter, so it'll load in the new data.

提交回复
热议问题