You're almost there, but values should be retrieved a little
differently, not with getIntArray:
Resources res = getResources();
TypedArray arr =
res.obtainTypedArray(R.array.<your_array_id_here>);
Drawable d = arr.getDrawable(2);
-- Kostya
18.03.2011 19:32, Marcin Orlowski ?????:
On 18 March 2011 02:20, droid-stricken <[email protected]
<mailto:[email protected]>> wrote:
Hi All,
I have some images in my res/drawable folder. Let's say img1.png,
img2.png and img3.png
I am currently creating an int array of these image IDs in Java like
this -
int[] imgIds = {R.drawable.img1, R.drawable.img2, R.drawable.img3};
Instead is it possible to create an int arr in one of res/values files
(say strings.xml) like this -
<integer-array name="img_id_arr">
<item>@drawable/img1</item>
<item>@drawable/img2</item>
<item>@drawable/img3</item>
</integer-array>
and then access it in Java via
getResources().getIntArray(R.array.ing_id_arr) ?
Not sure what you really want to acheive, but there's corelation
between drawable filename and assigned IDs. If you name your drawables
sequencially (i.e. "img000.png, img001.png, img100.png) then I think
you can safely assume IDs of 100th element is R.drawable.img000 + 100
Regards,
Marcin Orlowski
Tray Agenda <http://bit.ly/trayagenda> - keep you daily schedule handy...
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
Kostya Vasilyev -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en