The Html. fromHtml method in andorid

Source: Internet
Author: User

In android, there is an easy-to-Forget Html. fromhtml method, which means that
The strings in the box are HTML formatted, and many of them are supported,
 
However, you must note that <! -- Cdata --> escape, for example:
Java code
<String name = "htmlFormattedText">
<! [CDATA [
Text with markup for [B] bold [/B]
And [I] italic [/I] text.
 
There is also support for
<Tt> teletype-style </tt> font.
But no use for the <code> code </code>
Tag!
 
]> </String>
A large number of HTML tags are used in the preceding code:
Java code
TextView view = (TextView) findViewById (R. id. sampleText );
String formattedText = getString(R.string.html FormattedText );
Spanned result = Html. fromHtml (formattedText );
View. setText (result );
Or write as follows:
View. setText (Html. fromHtml ("<u> today's Friday </u> "));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.