转自http://yutinglong.iteye.com/blog/871461
1、在string.xml中添加一个字符串,其中含有可变字符%s,代码如下。
- <string name="login_about_title">Beem %s - About</string>
2、在代码中使用下列代码获取该字符串。
- String title = getString(R.string.login_about_title, "字符串");
其中“字符串”将会替换string.xml中的%s。
3、得到的字符串并打印,效果如下。
- title = "Beem 字符串 - About";
本文介绍如何在Android中使用字符串资源文件(string.xml)定义包含占位符的字符串,并通过代码实现动态替换占位符。



被折叠的 条评论
为什么被折叠?



