-1
int num++;
img.setBackgroundResource(R.drawable.card +num);

my pictures are in the drawable folder and they are ok! the problem is that i cant use R.drawable.card_1 ! how can i solve this!?

i've already tried the code below

int num++;
img.setBackfroundResource("R.drawable.card_"+num);

but its not working either!

one of my pictures name is card_1 to card_10 i want when user clicked on Next button the next picture comes!

1 Answers1

0

Try this:

getResources().getIdentifier("card_"+num, "drawable", getPackageName());
Andy
  • 49,085
  • 60
  • 166
  • 233