我正在尝试在我的 strings.xml 中引用格式化的字符串。我在谷歌上搜索,发现了这篇好文章:http: //developer.android.com/guide/topics/resources/string-resource.html
我遵循了它看起来的每一个细节,但打印出来的文本并不是它应该的样子。
首先,在我的资源下的strings.xml中,我将其定义为:
<string name="print_binary">This is the printout: %1$s</string>
在 .java 我放:
String fromString = "one";
Resources res = getResources();
onScreen = String.format(res.getString(R.string.print_binary), fromString);
这会在屏幕上显示以下文本:这是打印输出:%1$s
请指教