mercredi 16 janvier 2019

If Statment and Drawable

I have a few ImageViews that receive different drawable randomly. I want to change an ImageView depending on whether it contains a drawable or another, for example

if (R.id.img1 == R.drawable.dog) {
img1.setImageResource(R.drawable.squirrel)
}

Would this be well done? I'm not getting the image and I don't know why.

If not, how could I do it?

Aucun commentaire:

Enregistrer un commentaire