开发者

Reference a specific item in a <string-array> from a preferences XML?

Assuming I have a string array defined as:

<string-array name="settings"&开发者_如何转开发gt;
    <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?


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. ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜