Reputation: 522
In code, it's easy to use the Resources class to get an instance of an XML typed array resource and traverse its items. My question: is it possible to reference array resource items in XML itself as shown below
<resource>
<array name="items">
<item>Item One</item>
<item>Item Two</item>
<item>Item Three</item>
</array>
<string name="itemThree">@array/items[2]</string>
</resource>
The format shown above does not work. Does anyone know if that is possible using a different format?
Upvotes: 0
Views: 136
Reputation: 2416
I would just define itemThree in Java:
String itemThree = getResources().getStringArray(R.array.items)[2]
Ultimately, the XML gets inflated into Java objects, so it's not much difference IMO.
Upvotes: 1
Reputation: 1006789
No, but I think the reverse works. Define your strings as string resources and refer to them as @string/...
in the <item>
elements.
Upvotes: 1