`
ruirui516888
  • 浏览: 137051 次
文章分类
社区版块
存档分类
最新评论

Android string.xml文件中使用格式化符号%

 
阅读更多

实例:
要使用

Resource res = getResource();

String text = String.format(res.getString(R.string.welcome_message),username,mailCount);

需要在xml中定义

<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>

其中 第一个 %1$s 表示一个String
第二个 %2$d 表示一个浮点数


那么在 文件中定义个% 需要 用%% 来表示
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics