Reputation: 1061
I have a string array say
<string-array name="temp">
<item>
Some Data1
</item>
<item>
Some Data2
</item>
<item>
Some Data3
</item>
</string-array>
Suppose I want to get Some Data2 from this array, I know I can do
String temp[]=getResource().getStringArray(R.array.temp);
But instead of getting whole string array, I want only a specific item because data of whole string is too large, and I know its position. Please help.
Upvotes: 1
Views: 4720
Reputation: 1066
This is not possible.But If you want to do that just create string array in java class like
String arr[] = {"item1","item2","item3"}.
And access those value using arr[1];
Upvotes: 1
Reputation: 2982
Assuming the entry you want is at position 2 (just an example), then do:
String myEntry = getResource().getStringArray(R.array.temp)[2];
Upvotes: 3