android中strings.xml占位符

来源:互联网 发布:发淘宝链接如何粘贴 编辑:程序博客网 时间:2024/05/15 23:17

在strings.xml中我们存放需要使用的字符串。 但是有时候一些字符串的细节不能直接决定,需要之后考虑。

<string name="crime_report">%1$s!        The crime was discovered on %2$s. %3$s, and %4$s</string>
%1$s、%2$s等字符就是占位符,它们能够接收字符串。

java代码:

getString(R.string.crime_repost, x1, x2, x3, x4);

x1,x2,x3,x4在这里就是字符串,这4个字符串能够按顺序填入到%1$s、%2$s等位子上。

0 0
原创粉丝点击