在此行找到多个注释:

时间:2013-01-01 12:47:47

标签: android xml 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

这是我的代码

<resources>
   <string name="app_name">SpeedTest</string>
   <string name="network_edge">Network : EDGE</string>
   <string name="network_3g">Network : 3G</string>
   <string name="network_detecting">Network : Detecting </string>

   <string name="update_speed">%s kbit/sec</string>
   <string name="update_downloaded">Downloaded %s of %s</string>
   <string name="update_connectionspeed">Connection time %s ms</string>

   <string name="update_downloaded_complete">Downloaded %s @ %s kbit/sec</string>

</resources>

从这一行面对错误

<string name="update_downloaded">Downloaded %s of %s</string>

2 个答案:

答案 0 :(得分:18)

如果要替换两个字符串,这应该是正确的:

<string name="update_downloaded">Downloaded %1$s of %2$s</string>

请看这里:http://mobile.tutsplus.com/tutorials/android/android-sdk-format-strings/

答案 1 :(得分:10)

添加:

 <string name="update_downloaded" formatted="false">Downloaded %s of %s</string> 

因为你在这个字符串中有特殊字符。