string.xml 占位符 替换 文件

string.xml, 代码中


整数
<string name="num"><xliff:g>%1$d</xliff:g>苹果</string>                                              
String content = getString(R.string.num,  20);


百分比
<string name="num">百分比 : <xliff:g>^1</xliff:g>%</string>                             
CharSequence status = getText(R.string.num);
String content = TextUtils.expandTemplate(status,Integer.toString(80)).toString();

字符串
<string name="num">字符串 :<xliff:g>%1$s</xliff:g></string>                  
用法:String content = getString(R.string.num,"11111111");

你可能感兴趣的:(android随记)