Hey I got this xml array:
<resources>
<string-array name="colors">
<item>BLUE</item>
<item>CYAN</item>
<item>DARK_GRAY</item>
<item>GRAY</item>
<item>GREEN</item>
<item>LIGHT_GRAY</item>
<item>MAGENTA</item>
<item>ORANGE</item>
<item>PINK</item>
<item>RED</item>
<item>YELLOW</item>
<item>WHITE</item>
</string-array>
</resources>
I was trying such simple method which obviously can't work:
public int[] getColorsArray(int i) {
int[] allColors = MyApplication.getContext().getResources().getIntArray(R.array.colors); //this is probably wrong
int[] array = new int[i];
for (int j = 0; j < array.length; j++) {
array[j] = allColors[j]; //this is wrong
}
return array;
}
}
Is there a way to use such xml array?