【发布时间】:2019-07-02 02:20:15
【问题描述】:
单击按钮后,我尝试更新 TextView。 我使用 Strings.xml 来帮助我,并将其命名为“正义”。 不幸的是,当我单击按钮时,显然“正义”中的所有文本都添加了两次。一个带有粗体字体,另一个没有粗体字体。
我尝试添加“%s”,但它也不起作用。我使用的是 Android Studio 3.3.0。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tView = (TextView) findViewById(R.id.textView1);
clickhere = (Button) findViewById(R.id.button1);
clickhere.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String display = String.format(getString(R.string.justice, "%s"));
tView.setText(display);
}
});
}
当我点击按钮时,我希望只看到一份“正义”。这个错误是来自 Android Studio 还是我的代码有问题???有人,请帮帮我。谢谢你。
【问题讨论】: