This question already has an answer here:
-
Storing R.drawable IDs in XML array
4 answers
Is there a way to define an array in XML in which the elements are resource references?
For example (it doesn't work, but it explains what I want):
<integer-array name="actions_images">
<item>@drawable/pencil</item>
<item>@drawable/pencil</item>
<item>@drawable/pencil</item>
<item>@drawable/pencil</item>
<item>@drawable/pencil</item>
<item>@drawable/pencil</item>
</integer-array>
If I understand your question correctly, I think I know a workaround (since accessing them via getResources().getIntArray() doesn't work). (You can read more here, that is the source I took the workaround from.)
TypedArray ar = context.getResources().obtainTypedArray(R.array.my_array);
int len = ar.length();
int[] resIds = new int[len];
for (int i = 0; i < len; i++)
resIds[i] = ar.getResourceId(i, 0);
ar.recycle();
// Do stuff with resolved reference array, resIds[]...
for (int i = 0; i < len; i++)
Log.v (TAG, "Res Id " + i + " is " + Integer.toHexString(resIds[i]));