在
<item>100% foo 40%bar</item>
产生这些错误:
Multiple annotations found at this line:
- error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
- error: Found tag </item> where </string-array> is expected
添加 formatted="false"不会改变任何事情。
<item>100% foo 40%bar</item>
导致相同的错误消息。 WTH?
<item>100% foo 40bar</item>
<item>100 foo 40%bar</item>
<item>100% foo 40%</item>
一切都会好起来的。 用\% 转义它会被忽略,导致同样的错误。 %% 不会导致错误,但我会得到 %%。
最佳答案
%
是 XML 中的保留字符,如 <
, >
, ETC。
使用%%
对于每个 %
您在字符串资源中使用。
关于android - 在 Android 中转义多个 “%” 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9386411/