I have 3 sound files in my raw folder and then this in /values/
sounds.xml
<resources>
<array name="sounds">
        <item name="sound1" type="raw">R.raw.sound1</item>
        <item name="sound2" type="raw">R.raw.sound2</item>
        <item name="sound3c" type="raw">R.raw.sound3</item>
</array>
</resources>

I'm trying to load all the resource Id's into an int array so I can
pass it into the media player to say (mapping all sounds from a button
to a sound).

I have tried everything I could find googleing this question:
TypedArray ar = context.getResources().obtainTypedArray(resourceId);

                int len = ar.length();
                int[] resIds = new int[len];
                for (int i = 0; i < len; i++)
                    resIds[i] = ar.getResourceId(i, 0);
                ar.recycle();

Doesn't work, I get back an array of 0's. And of course
getResources().getIntArray(R.array.sounds); doesn't work either. I'm
going to keep trying (new to the API, so still reading/messing around)
but if anyone has a solution, or is the reflection method the only
workaround?

Thanks

-- 
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

Reply via email to