I was just wondering if there is any way to reference a resource using a string.
Say you had 10 images in your drawable folder called 'img1' 'img2' 'img3' etc......
Is there any way of doing this? Or will I just have to use if statements to work out which image to use?
Say you had 10 images in your drawable folder called 'img1' 'img2' 'img3' etc......
PHP:
int imgNum = 2;
String imgName = "img"+imgNum;
Drawable d = (Drawable) getResources().getDrawable(R.drawable.imgName);
Is there any way of doing this? Or will I just have to use if statements to work out which image to use?