在string.xml中定義
?<string name = “myname”>他今年%1$d歲了</string>
在程序中
String string = context.getResource().getString(R.string.myname);
MyTextView.setText(String.format(string,8));
打印 他今年8歲了
%d 整數(shù)
%f 浮點(diǎn)數(shù)
%s字符串
也可以在String.xml中%2添加多個值侍匙,依次在代碼中填入相應(yīng)值即可