strings.xml中的Android变量

在某处我读了如何在 XML文档中使用变量.他们说这很简单,我想是的.我在 Android strings.xml文件中成功地使用了它.我一整天都在使用它,直到突然android停止解析它并停止将其视为变量.

我用这种方式使用它:

<resources>
<string name="some_string">string1</string>
<string name="another_string"> {$some_string} trolololo </string>
</resources>

并通过java访问它:getApplicationContext().getString(R.strings.another_string);

getApplicationContext().getString(R.strings.another_string);

在我用来接收字符串的输出中:

string1 trolololo

现在我只收到:

{$some_string} trolololo

有谁知道什么是错的?我知道Android的XML可能与标准XML不同,但是它可以用于工作. Awww …感谢您的任何建议.

这将解决您的问题:
<resources>
    <string name="some_string">string1</string>
    <string name="another_string">@string/some_string trolololo</string>
</resources>

现在getApplicationContext().getString(R.strings.another_string)的输出将是string1 trolololo.

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念