【问题标题】:String cannot contain two '%'字符串不能包含两个 '%'
【发布时间】:2015-06-17 06:29:58
【问题描述】:

这一切都发生在我的Project -> res -> values -> strings.xml 文件中。

我的字符串如下:

<string name="Bellowy">"During its action, if HP is less than 50%, increase all your creatures ATK by 30% during their next basic ATK"</string>

控制台输出此错误strings.xml:98: error: Unexpected end tag string。我已经确定在 R.java 文件中没有正确注册两个 % 标志。如何修复此错误并在我的 Strings.xml 中添加两个 % 标志?

【问题讨论】:

标签: java android xml string


【解决方案1】:

由于percent encoding '%' 是转义字符,它一定会造成一些麻烦。你可以使用 %%

【讨论】:

    【解决方案2】:

    如我所用,您可以通过两种方式消除此问题

    添加格式化属性

    <string name="Bellowy" formatted="false">"During its action, if HP is less than 50%, increase all your creatures ATK by 30% during their next basic ATK"</string>
    

    添加 %% 而不是 %

    <string name="Bellowy">"During its action, if HP is less than 50%%, increase all your creatures ATK by 30%% during their next basic ATK"</string>
    

    【讨论】:

      猜你喜欢
      • 2013-04-08
      • 1970-01-01
      • 2013-01-09
      • 2018-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-27
      相关资源
      最近更新 更多