0

I already know how we can do that, but those are not for my use. I want it just within set text without creating any new string in java. I found many questions already on stackoverflow, But they all are different for me in this case.

Here what i've tried :

printResult.setText(String.valueOf(Html.fromHtml("<b>" +printNumbers+ "</b>" )));
CODAR747
  • 230
  • 1
  • 12
  • Does this [answer](https://stackoverflow.com/a/6200841/11023871) provide the information you have requested? From what I understand, it's just a simple `TextView` (with all the characters bolded), so this should be sufficient – David Buzatu Jul 24 '20 at 10:56
  • No, that's not what i'm looking for. That will be for all text. I need just for a specific word as i printed above in my code that is `printNumbers` –  Jul 24 '20 at 11:04
  • You can use a [`StyleSpan`](https://developer.android.com/reference/android/text/style/StyleSpan) for that. – Michael Jul 24 '20 at 11:05

1 Answers1

0

The method String.valueOf() will convert the Spannable to String and your formatted string will lost. So, remove the String.valueOf() method and use below code:

printResult.setText(Html.fromHtml("<b>" +printNumbers+ "</b>" ));
Shalu T D
  • 3,921
  • 2
  • 26
  • 37