Reputation: 255
I'm a beginner Android Developer
.
I would like to find out how I could access a string array out of
string.xml and use it.
I searched the internet inside out and found nothing.
I found ways to put it into text-view right away, but that's not what I want to do. So, basically, I want to put the string array into another array
.
string.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="Solar System">
<item>Sun</item>
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
<item>Mars</item>
<item>Jupiter</item>
<item>Saturn</item>
<item>Uranus</item>
<item>Neptune</item>
So I want this xml string array into a java string array
Thank's for the POSITIVE HELP, I'm sorry, I thought that way that was shown by many of you didn't work. It was just another error in my program.
-Thanks
Upvotes: 0
Views: 204
Reputation: 11939
Seriously? The example where you got that from even shows how you to access it:
Resources res = getResources();
String[] planets = res.getStringArray(R.array.Planets);
Upvotes: 1
Reputation: 133560
Use the below
String[] planets = getResources().getStringArray(R.array.Planets);
Upvotes: 1