string.xml问题代码 <string name="msg">书名:%s\n价格:%d</string> 异常信息 Error:(949) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?Error:(949) Unexpected end tag stringEr
%n$ms:代表输出的是字符串,n代表是第几个参数,设置m的值可以在输出之前放置空格 %n$md:代表输出的是整数,n代表是第几个参数,设置m的值可以在输出之前放置空格,也可以设为0m,在输出之前放置m个0 %n$mf:代表输出的是浮点数,n代表是第几个参数,设置m的值可以控制小数位数,如m=2.2时,输出格式为00.00 比如 <string name="section_format">Hello World from section: %1$d</string&g
1.遇到如下错误的时候说明你需要在单引号签名加转义字符(\): 1 Description Resource Path Location Type error: Apostrophe not preceded by \ (in Search' Titles) strings.xml 只要将定义的字符串中的单引号('), 修改为(\')即可,当然有些时候并没有任何提示(在做MTK平台的时候,在有些时候由此导致的无法编过并没有任何象征性的提示)
XML Code 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511
反复检查后发现是string.xml中的 % 导致编译失败, 这是由于新的SDK采用了新版本的aapt(Android项目编译器),这个版本的aapt编译起来会比老版本更加的严格,然后在Android最新的开发文档的描述String的部分,已经说明了 如何去设置 %s 等符号,下面是文档片段: If you need to format your strings using String.format(String, Object...) , then you can do so by putt