%1$s表示替换的为String类型
%1$d表示替换的为int类型
数字表示替换字符串中要替换的位置,若一个字符串要替换两个int类型,在替换位置分别写%1$d和%2$d.
%s 、%d为缩写方式,只替换一个位置,可以这么写
替换方式
strings.xml中定义
<string name="remove_family_sure">确定要删除亲友‘%s’
吗?</string>
在类中调用
String.format(mActivity.getResources().getString(R.string.remove_family_sure),"张三"))
输出结果就会拼接上。
转载请注明原文地址: https://ju.6miu.com/read-667635.html