Reputation: 4587
If I put simple HTML formatting tags, such as <b>...</b> into a string resource and display the string in a TextView, the expected formatting is applied. But how can I do this if I build up my own String and display it? If I do something like String str = "This is <b>bold</b>";, the actual tags get displayed -- not the expected bolding.
Do I have to run the string through some other method to cause the tags to be recognized as tags?
Upvotes: 8
Views: 13408
Reputation: 52229
You have to use Html#fromHtml
String input = "<b>bold</b>";
myTextView.setText(Html.fromHtml(input));
Upvotes: 21