user10995231
user10995231

Reputation:

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.

Upvotes: 1

Views: 570

Answers (2)

Talha Bilal
Talha Bilal

Reputation: 187

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.

Upvotes: 1

Beyazid
Beyazid

Reputation: 1835

You can use recyclerview or gridview. Then use Glide library in your adapter

ImageView imageView = (ImageView) findViewById(R.id.imageView);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(context).load(yourGif).into(imageViewTarget);

or

ImageView imageView = (ImageView) findViewById(R.id.imageView);
Glide.with(context).asGif().load(yourGif).into(imageView);

Upvotes: 1

Related Questions