[英]Storing formattable string resource in string.xml
如何将可格式化的字符串资源存储在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$
等。
尝试更改HTML编码的“%”字符。 例如要插入“ ...”,您必须编写代码
"…"
“%”的代码是
"%"
您可以在此页面中看到它: http : //www.ascii.cl/htmlcodes.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.