ITeye博客

获取string.xml中的可变字符串

yutinglong · 2011-01-14 15:47 · Android · 移动开发 · Markdown

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"; 

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。