How to refresh a GridView?

后端 未结 9 2285
清歌不尽
清歌不尽 2020-12-01 08:01

I have a GridView which is pretty similar to the Google tutorial, except that I want to add the ImageViews on runtime (via a subactivity). The results are okay, but the layo

9条回答
  •  离开以前
    2020-12-01 08:14

    @flyerz @snagnever

    Together you guys have got it. It should be:

    adapter.notifyDataChanged();
    grid.invalidateViews();
    

    This will flag the adapter that its data has changed, which will then be propagated to the grid whenever after the invalidateViews() method is called.

    Glad I found this question because I could not figure out how to add items to the grid after its been rendered.

提交回复
热议问题