i am trying to use image array and display image when image not load or any error occur.
Any ideas of how to achieve this?
this is my code
int[] myImageList = new int[]{R.drawable.wallpaper_1, R.drawable.wallpaper_2,R.drawable.wallpaper_3,
R.drawable.wallpaper_4,R.drawable.wallpaper_5,R.drawable.wallpaper_6};
int img=myImageList[position%myImageList.length];
Glide.with(mContext)
.load(album.getUrl())
.error(myImageList[img])
.into(holder.image);
in my api i am getting too much null image so i have to manage this by setting random image on error
This solution is based on your above comment:
Generate random number
int[] myImageList = new int[]{R.drawable.wallpaper_1, R.drawable.wallpaper_2,R.drawable.wallpaper_3,
R.drawable.wallpaper_4,R.drawable.wallpaper_5,R.drawable.wallpaper_6};
Random random = new Random();
int randomNumber = random.nextInt(myImageList.length);
Glide.with(this)
.load(album.getUrl())
.apply(new RequestOptions()
.error(myImageList[randomNumber]))
.into(holder.image);