Last active
March 1, 2018 03:41
-
-
Save luck-alex13/f5307eb64741ddb18bf0a188cbc9d952 to your computer and use it in GitHub Desktop.
Default html and links support in TextView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textView.setText(fromHtml(text)); | |
textView.setMovementMethod(LinkMovementMethod.getInstance()); | |
public static Spanned fromHtml(String html) { | |
Spanned result; | |
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { | |
result = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY); | |
} else { | |
result = Html.fromHtml(html); | |
} | |
return result; | |
} | |
//Important: Don't forget to remove autoLink="web" if you are calling setMovementMethod() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment