In fact Html.fromHtml(String source) is now considered obsolete. This, however, does not imply that it cannot be used. Because there is no other option, in case you want the app to run in versions prior to N.
The method that replaces it is Html.fromHtml(String source, int flag)(1).
To the parameter flag
one or more (separated by the operator or |
) of the constants that the class Html declaring.
Each of these "flags" indicates how the html in source
should be "interpreted" when constructing the Spanned returned by function.
For example, the constant FROM_HTML_SEPARATOR_LINE_BREAK_LIST
indicates which text inside elements <ul>
are by default separated from other texts by a newline.
(1) - Use the constant Html.FROM_HTML_MODE_LEGACY to obtain the behavior prior to version N.
Very good Ramaral. + 1. I didn’t expect any other answer than this.
– viana
@ramaral, I would like to replace this obsolete statement with this one you mentioned, but it does not accept null as int flag. I just need to format some links. Can you tell which tag I should use?
– Rene Freak
@Renefreak Use the constant
Html.FROM_HTML_MODE_LEGACY
– ramaral