Hi all,
I have two arrays in my Activity / java file --- 1-dimensional and
2-dimensional as follows
private String[] groups = { "People Names", "Dog Names", "Cat Names",
"Fish Names" };
private String[][] children = {
{ "Arnold", "Barry", "Chuck", "David" },
{ "Ace", "Bandit", "Cha-Cha", "Deuce" },
{ "Fluffy", "Snuggles" },
{ "Goldy", "Bubbles" }
};
Here I can access them with no prob.
But what if I want to define them in Strings.xml and then to access from my
activity .
I am able to access 1-d array here in java file as below:
String[] groups = getResources().getStringArray(R.array.group_array);
But what to do for 2d array?
Here is my Strings.xml
<?xml version="1.0" encoding="utf-8" ?>
- <file:///F:/strings.xml#> <resources>
<string name="*hello*">Hello World, bitmapmesh!</string>
<string name="*app_name*">bitmapmesh</string>
- <file:///F:/strings.xml#> <string-array name="*group_array*">
<item> People Names </item>
<item> Dog Names </item>
<item> Cat Names </item>
<item> Fish Names </item>
</string-array>
- <file:///F:/strings.xml#> <string-array name="*child*">
<item index0="*0*" index1="*0*"> Arnold </item>
<item index0="*0*" index1="*1*"> Barry </item>
<item index0="*0*" index1="*2*"> Chuck </item>
<item index0="*0*" index1="*3*"> David </item>
<item index0="*2*" index1="*0*"> Ace </item>
<item index0="*2*" index1="*1*">Charlottetown</item>
<item index0="*3*" index1="*0*">Zürich</item>
<item index0="*3*" index1="*1*">Bern</item>
</string-array>
</resources>
*Now, how to access this 2d array from strings.xml in my Activity?*
Am I doing something wrong here in defining 2d array in strings.xml
Please suggest me what I can do in this situation.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en