Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在XML数组中引用XML字符串(Android)_Android - Fatal编程技术网

在XML数组中引用XML字符串(Android)

在XML数组中引用XML字符串(Android),android,Android,在arrays.xml中 <string-array name="my_items"> <item>My item 1</item> <item>My item 2</item> <item>My item 3</item> </string-array> 我的项目1 我的项目2 我的项目3 在strings.xml中 <resources> <string n

在arrays.xml中

<string-array name="my_items">
  <item>My item 1</item>
  <item>My item 2</item>
  <item>My item 3</item>
</string-array>

我的项目1
我的项目2
我的项目3
在strings.xml中

<resources>
  <string name="item1">My item 1</string>
  <string name="item2">My item 2</string>
  <string name="item3">My item 3</string>
</resources>

我的项目1
我的项目2
我的项目3

我想引用strings.xml中数组“My item 1”中的字符串。我该怎么做?你不能。也可以做相反的操作:在
中设置
@string/item1

哦,是的,这就是我的意思。我就是这样做的

<string-array name="my_items">
  <item>@string/item1</item>
  <item>@string/item2</item>
  <item>@string/item3</item>
</string-array>

@字符串/项目1
@字符串/项目2
@字符串/项目3

它在Android 1.6中得到了正确的解析

如果它们在同一个xml文件中,对我来说就不起作用了……我想我应该添加一个重要的提示*——将Ubuntu与Eclipse 4.2结合使用如果
@string
无法识别,请尝试将其输入IDE,而不是复制和粘贴。