小编bpa*_*ski的帖子

strings.xml中的Android变量

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

我用这种方式使用它:

<resources>
<string name="some_string">string1</string>
<string name="another_string"> {$some_string} trolololo </string>
</resources>
Run Code Online (Sandbox Code Playgroud)

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

getApplicationContext().getString(R.strings.another_string);
Run Code Online (Sandbox Code Playgroud)

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

string1 trolololo
Run Code Online (Sandbox Code Playgroud)

现在我只收到:

{$some_string} trolololo
Run Code Online (Sandbox Code Playgroud)

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

xml variables parsing android

8
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

parsing ×1

variables ×1

xml ×1