0

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.

2
  • 1
    but this is deprecated it is, starting from android n. Android studio is not allowing me to use it. That's not true. Commented Oct 14, 2016 at 15:44
  • Either continue using fromHtml(String), or on API Level 24+ devices switch to fromHtml(String, int), passing in FROM_HTML_MODE_LEGACY as the flag. And, as Blackbelt points out, please edit your question to explain, in detail, what "is not allowing me to use it" means. Commented Oct 14, 2016 at 15:47

2 Answers 2

1

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");
}
Sign up to request clarification or add additional context in comments.

Comments

0

You can use Html.FROM_HTML_MODE_LEGACY as the second parameter.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.