emir
emir

Reputation: 1406

Converting html entities to characters in Android

I am parsing JSON data and using it in Android textview.

And I am getting &lt; instead of <, etc.

I tried with

Html.fromHtml("ur text here");

but this is deprecated and Android studio is not allowing me to use it.

As I saw in google documentation i need to use 2 parameters, from which other is some int Flag, and I don't know how to use it.

Upvotes: 0

Views: 255

Answers (2)

muthuraj
muthuraj

Reputation: 1102

You can use Html.FROM_HTML_MODE_LEGACY as the second parameter.

Upvotes: 0

Umesh Singh Kushwaha
Umesh Singh Kushwaha

Reputation: 5741

Just use

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
    Html.fromHtml("ur text here",Html.FROM_HTML_MODE_LEGACY);
} else {
    Html.fromHtml("ur text here");
}

Upvotes: 1

Related Questions