加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

【xml String format】error: Multiple substitutions specified

发布时间:2020-12-16 09:42:43 所属栏目:百科 来源:网络整理
导读:今天大篇的粘贴arrays.xml中出现了这个问题: Typeerror: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? 对应的代码是: string name ="template_user_agent" "%s/%s (Linux; Android)

今天大篇的粘贴arrays.xml中出现了这个问题:

Typeerror:

Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?

对应的代码是:

<string name="template_user_agent">"%s/%s (Linux; Android)"</string>

解决办法是:

1 使用%%或%,如:

>"%%s/%%s (Linux; Android)" 2 添加 formatted="false" 属性

="template_user_agent" formatted="false" 这个错误和ADT的版本有关,旧版本不会出现这个提示。

更新修正:

用上面两种方法,会使得字符串丧失格式化的能力(比如使用 getResource().getString(String,Object...)这个方法),保持格式化字符串的做法,可参考:http://www.52php.cn/article/p-dgefeqho-zk.html,修改如下:

>"%1$s/%2$s (Linux; Android)">

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读