0

I have files in the folder drawable which are named in one way:

v[versionNumber]i[nameOfFile] 

Example: v1i2

And in the activity code I have a

String fileName = "v1i2;//name of the desired resource id
int drawableId = GETTHISID(fileName);

Is it possible to get id of this drawableId resource?

Yoda
  • 17,363
  • 67
  • 204
  • 344
  • possible duplicate of [Android, getting resource ID from string?](http://stackoverflow.com/questions/4427608/android-getting-resource-id-from-string) – laalto Jun 05 '13 at 07:35

1 Answers1

1

Try:

for (int i=0;i<10;i++){
    int id = getResources().getIdentifier("v"+i+"i"+i,"drawable", getPackageName()); 
}
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295