How to refresh a GridView?

后端 未结 9 2311
清歌不尽
清歌不尽 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:32

    None of these answers actually worked for me and I had to mash all of them together. To actually get the GridView to update, you need to do this:

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

    Hope this helps anyone who couldn't get the other solutions to work.

提交回复
热议问题