Suppose I have a resource xml file like this:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<array name="difficulties">
<item>
<integer name="level">1</integer>
<integer name="fixed_blocks">2</integer>
<integer name="color_count">2</integer>
</item>
<item>
<integer name="level">2</integer>
<integer name="fixed_blocks">4</integer>
<integer name="color_count">3</integer>
</item>
<item>
<integer name="level">3</integer>
<integer name="fixed_blocks">6</integer>
<integer name="color_count">3</integer>
</item>
</array>
</resources>
How can I get the integer values from an item by name? The TypedValue‘s API doesn’t seem to contain any methods for this. If this is not possible with the TypedArray how IS it?
If I can get a value from an item by its ordinal it will be OK too.
I don’t recall this being possible(but I could be wrong). Judging by the structure of an item(in the
difficultiesarray) you could do something else, you could use an array of integer arrays. Knowing that the item array haslevelat the first position,fixed_blocksas the second position etc you could easily get the values. An example of this you can find here Android Resource – Array of ArraysEdit:
Is this the method you’re looking for?
and the array will be: