Android开发: strings.xml文件中的错误

来源:互联网 发布:苹果8打不开数据 编辑:程序博客网 时间:2024/05/17 23:27
编辑strings.xml的时候
在行<string name="myurl">http://code.dd.com/rr?q=%rr.55</string>
提示下面的错误
Multiple annotations found at this line:
- error: Multiple substitutions specified in non-positional format; did you mean to add 
the formatted="false" attribute?
- error: Unexpected end tag string

出现这个错误的原因主要是因为strings字串中包含百分号(%),


有几种方式解决
1.用两个百分号表示一个百分号即
<string name="myurl">http://code.dd.com/rr?q=%%rr.55</string>
2.用转义符表示
<string name="myurl">http://code.dd.com/rr?q=\%rr.55</string>
3.根据错误提示可知,如果字符串无需格式化,可在<string 标签上增加属性:formatted="false",即

<string name="myurl" formatted="false">http://code.dd.com/rr?q=%rr.55</string>

来自东子的博客