I want setImageResource for ImageButton programmatically, based on a variable.
For example: if size = 5, I want setImageResource to be R.drawable.five
if size=6, I want to setImageResource to R.drawable.six
Unfortunately, I have too many of them, so the if-else or switch gets tired.
Is there a way to achieve something like: R.drawable.size?
Thank you, Chris
source
share