ADT 在 Strings.xml 中显示错误

发布于 2024-10-08 08:12:07 字数 421 浏览 0 评论 0 原文

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 个格式说明符时,我就会收到此错误。

I updated my ADT to the latest version after Gingerbread was released. And now

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

shows the following error

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

Previous ADT version worked fine. Am I doing something wrong? I get this error whenever there are more than 1 format specifiers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

策马西风 2024-10-15 08:12:07

或者,您也可以修改 % 格式说明符以使用参数索引,如下所示:

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

Android 参考文档

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.

昨迟人 2024-10-15 08:12:07

尝试执行以下操作

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

详细的解释可以在这个问题的答案中找到:Android XML百分比符号

Try doing the following

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

The detailed explanation can be found in the answer to this question: Android XML Percent Symbol

緦唸λ蓇 2024-10-15 08:12:07

我还看到了由于拼写错误而导致的错误:%$3s。应为%3$s

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

I'm also seeing this error cause of a typo:%$3s. Should be %3$s.

Just for somebody who is stupid like me:)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文