1

I am building an Andorid application. I have this String array which contains the values for the image files:

String[] stringArray = new String[]{ "R.drawable.image1", "R.drawable.image2 ", "R.drawable.image3", "R.drawable.image4"};

Is is it possible to convert the stringArray to something like that, if yes h so the Android app can read the resource values properly ? If yes then how ?

int[] intArray = new int[]{R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4};
radioaktiv
  • 2,437
  • 4
  • 27
  • 36

1 Answers1

1

you can get the identifiers if you know the resource type. Maybe just tokenize the string and get the type, then call one of theese methods answered here: How to get a resource id with a known resource name?

Community
  • 1
  • 1
eduyayo
  • 2,020
  • 2
  • 15
  • 35