I have some images in my res/drawable
folder. Let\'s say img1.png
,
img2.png
and img3.png
. I am currently creating an inte
Use just "array" instead of "integer-array". See Typed Array in the developer guide.
I think it's best to keep them in code.
private static final int[] AVATARS = new int[]{
R.drawable.ava_1, R.drawable.ava_2, R.drawable.ava_3...};
See XML integer array, resource references, getIntArray
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]));
Make a LevelListDrawable. Although it is not exactly what you want, but pretty much achievable.