This question already has an answer here:
- Storing R.drawable IDs in XML array 4 answers
how would I reference a drawable resource from the string xml file? I want to do
<string-array name="my_array">
<item>@drawable/my_image</item>
...
How would I do that?
I guess you are trying to store all of your image resource names (as string) inside an array and be called when you write your java code?
Would get your string array into an array. You can get the item you want by accessing the array as usual.
http://developer.android.com/guide/topics/resources/string-resource.html
If you are trying to achieve to load a list of images to a gridview, you might want to refer to this:
http://developer.android.com/guide/topics/ui/layout/gridview.html
They have placed the array in the base adapter, like this:
Which you can easy use just like how you would access an array.
for arrays of drawables ids, don't use string array just use
<array>
then to use them, get a
TypedArray
if the idsand don't forget when you're done with the resource id and array to recycle it