gpt4 book ai didi

android - 在 string.xml 中存储可格式化的字符串资源

转载 作者:行者123 更新时间:2023-11-29 21:11:12 25 4
gpt4 key购买 nike

如何在 res/value/string.xml 中存储可格式化的字符串资源,以便它不会破坏我的 R.java?目前我只有以下内容,但它不起作用。

<string name="format_able">This is a formatable string resource with %s and %s as place holders</string>

但 eclipse 不会对其进行红线标注。所以我花了几个小时才弄清楚这就是我的 R 没有生成的原因。那么如何转义 %s 呢?

最佳答案

我终于在 http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling 找到了答案特别是

 <string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>

我遗漏了 1$2$

关于android - 在 string.xml 中存储可格式化的字符串资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22765124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com