【发布时间】:2012-07-16 20:06:52
【问题描述】:
在某处我读到了如何在 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 不同,但它曾经可以工作。哇...感谢您的建议。
【问题讨论】:
-
清理项目后尝试,然后再次
run。 -
嗯...我想知道,这是否也适用于其他类型,如 int 或 int[]
标签: android xml parsing variables