I tried to update a TextView after button is clicked. I used the Strings.xml to help me out and named it as "justice". Unfortunately when I click the button, apparently that all text in "justice" is added twice. One with bold fonts and another without bold fonts.
I tried added "%s", but it doesn't work either. I used 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);
}
});
}
I expect to see only one copy of "justice" when I click the button. Does this bug comes from Android Studio or something is wrong with my code??? Someone, help me please. Thank you.