I’m trying to learn Java for Android and not sure how to even Google this. I was wondering if there’s a way to programmably attach a number to the end of R.id.variable or R.drawable.variable etc?
Basically I have several images labeled image1, image2, image3, etc. I want to update the ImageView drawable to be based on another variable. So if that passed variable is “1”, it will update the view to “image1”. If it’s “2” it will update “image2” and so on but I don’t know if there’s a way to attach “1” to “R.drawable.image” when calling the update.
How is the best way to go about doing this?
Maybe help:
Your images: image1.png, image2.png, …., imageN.png
You can find their id :
So: