0

Assuming I have a string array defined as:

<string-array name="settings">
    <item>not very unique</item>
    <item>not very unique</item>
    <item>slightly more unique</item>
</string-array>

Is there a way to reference an item, by its index in the array, from a preferences XML?

I know how to reference the entire array:

android:entries="@array/settings" 

But is there a way to reference only one item from the array?

1 Answer 1

1

Well no, there is no way, but you could do something like this:

<string name="mystring_1">awesome string is awesome</string>
<string name="mystring_2">even more awesome string</string>
<string-array name="mystrings">
    <item>@string/mystring_1</item>
    <item>@string/mystring_2</item>     
</string-array>

So you basically reference another string in your resources, that is referenced in your string array. ;)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! That's an excellent solution. I just managed to implement your proposed solution and it works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.