Pratik Bhat
Pratik Bhat

Reputation: 7614

Android: Html.fromHtml() method weird issue

I am facing a weird issue:

My source string for Html.fromHtml() is as follows:

<strong>Terrible experience with Nikko hotel</strong><br />It was not easy to cancel booking. I called to cancel books, but they still chraged us two full days. A reason was we were late ten minutes in calling to cancel. They explained us very kindly that I can only cancel the first day. But they charged after then.\nSick."

which is retrieved from a json response

Now, when I display it using setText as follows:

commentbox.setText(Html.fromHtml(cmnt.getString("cmnt")));

but the output which i see is as follows:

enter image description here

Why is it giving me italic text instead of bold?

Upvotes: 4

Views: 2328

Answers (1)

Hanry
Hanry

Reputation: 5531

This can be a LIMITATION as described here:

the Html.fromHtml() method in Android that creates a SpannedString from HTML source flips <em> and <strong> tags, so what you might be used to seeing in boldface turns into italics and vice-versa. This should only be an issue if you are displayng the generated HTML in a TextView — WebView in particular should behave more normally.

Upvotes: 8

Related Questions