Search code examples
androidgifandroid-gridview

How to add multiple GIFs to Android GridView


How to add multiple GIFs to Android GridView? Let's assume that we have a 4*4 grid (16 cells), with a different individual animated GIF image being shown in each cell in such a way that each image is animating on its own. Therefore creating a GIF of 16 different videos/animations, all playing at the same time in 16 separate cells.


Solution

  • First Step

    In you GridAdapter make a function

    public void upadteList(List<yourGifList> list){
             this.gifList = list;
             notifyDataSetChanged();
         }
    

    then in OnBind Method call
    Glide.with(context).asGif().load(gifList).into(imageView);

    Second

    In your activity call upadteList() method
    gridAdapter.updateList(imagesList);

    Note : i am assuming you are already have a recyclerView setup.