zomlaaa95 zomlaaa95 - 25 days ago 5x
Android Question

Get resource id from typedarray

I have this file array.xml and I want to get the item value from an array.
How can I do that? I have tried with getInt but that returns 0. All help is welcome.

<array name="firstAd">


First, change each item to @id/object instead of R.id.object, then change the tag from array to integer-array, and move the code to your 'integer.xml' resource file.


<integer-array name="firstAd">

Then, programmatically use a TypedArray, like so:

TypedArray firstAd = getResources().obtainTypedArray(R.array.firstAd);
int resourceId = firstAd.getResourceId(index, defValue);