2

I want access to a picture using

image.setImageResource(R.drawable.photo1);

How can I change "photo1" to "photo" + # (incremented number) so that I can use it with an iteration?

JPM
  • 9,077
  • 13
  • 78
  • 137
ZanattMan
  • 746
  • 1
  • 7
  • 26

1 Answers1

3
int resID = getResources().getIdentifier("photo"+1,"drawable", getPackageName());
image.setImageResource(resID); 
Cristian
  • 198,401
  • 62
  • 356
  • 264