在某处我读了如何在
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.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。