参考在℃的特定项目;字符串数组>从preferences XML? [英] Reference a specific item in a <string-array> from a preferences XML?

查看:225
本文介绍了参考在℃的特定项目;字符串数组>从preferences XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我定义为一个字符串数组:

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>

有数组中引用一个项目,通过其索引,从preferences XML的方式?

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

这篇关于参考在℃的特定项目;字符串数组&GT;从preferences XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆