I'm developing a java Android app and i'm having a XML-Resource, it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- first pattern -->
<integer-array name="pattern_a">
<item>1</item>
<item>0</item>
<item>1</item>
</integer-array>
<!-- second pattern -->
<integer-array name="pattern_b">
<item>1</item>
<item>1</item>
<item>0</item>
</integer-array>
<!-- broad configuration -->
<string name="config_broad_name">broad</string>
<integer-array name="config_broad_pattern">@array/pattern_a</integer-array>
<!-- small configuration -->
<string name="config_small_name">small </string>
<integer-array name="config_small_pattern">@array/pattern_b</integer-array>
</resources>
I'm creating a Configuration and set some values from my resource files, which seems easy straight forward...
public Configuration createConfiguration(){
Configuration configBroad = new Configuration();
String configName = getResources().getString(R.string.config_broad_name);
int[] pattern = getResources().getIntArray(R.array.config_broad_pattern);
configBroad.setName(configName);
configBroad.setPattern(pattern);
return configBroad;
}
Problem: int[] pattern is an empty int[] (like int[]{})
what would really help, something like this:
int patternId = getArrayId(getResource(), R.string.config_broad_pattern);
configBroad.setPatternId(patternId); //setting just the id, not the whole pattern
then i could retrive the value itself, or even better - set the id on my config instead of the array.
i know, there a ton's of explanations on how to work on this problem with string[] (like array_of_array) and @image/...-Arrays but i couldn't find any one with integer array (especially when looking for Typed-Array i couldn't find help)