27

在 Gingerbread 发布后,我将 ADT 更新到了最新版本。现在

<string name="date_format">%d:%d %s</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

以前的 ADT 版本运行良好。难道我做错了什么?每当有超过 1 个格式说明符时,我都会收到此错误。

4

3 回答 3

46

Or, alternatively, you can modify your % format specifiers to use argument indices, like so:

<string name="date_format">%1$d:%2$d %3$s</string>

More info on the Formatter class in the Android Reference Docs.

于 2010-12-29T23:09:15.947 回答
39

尝试执行以下操作

<string name="date_format" formatted="false">%d:%d %s</string>

详细解释可以在这个问题的答案中找到:Android XML Percent Symbol

于 2010-12-19T19:07:29.690 回答
0

我也看到了这个错误的错字原因:%$3s。应该是%3$s

只适合像我这样愚蠢的人:)

于 2015-11-26T09:09:34.483 回答