如何在res/value/string.xml
中存储格式化字符串资源,以便它不会破坏我的R.java
?目前我只是拥有以下内容,但它不起作用。
<string name="format_able">This is a formatable string resource with %s and %s as place holders</string>
但是日食没有对它进行红线化。所以花了我几个小时才发现这就是我的R没有被生成的原因。那么如何逃避%s
?
答案 0 :(得分:2)
我最后在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$
等
答案 1 :(得分:0)
尝试更改其HTML编码的“%”字符。例如,要插入“...”,您必须编写代码
"…"
“%”的代码是
"%"
您可以在此页面中看到它:http://www.ascii.cl/htmlcodes.htm