Explanation of Html class for Android Development

Source: Internet
Author: User
Tags convert text to html

Explanation of Html class for Android Development

During Android development, Html classes are often ignored. This class is actually very simple, that is, parsing HTML Tag text into common style text. Let me take a look at the specific introduction of this class.

Class Structure:

Java. lang. Object

?

Android. text. Html

Class Overview:

This class is used to process HTML strings and convert them into printable style text. But not all HTML tags are supported.

Public method:

Simply put, it should have four methods:

Public Methods

Static String

EscapeHtml (CharSequence text)

Returns Html Escape characters from a given representative name.

Static Spanned

FromHtml (String source)

Returns the displayed style text from the Html string.

Static Spanned

FromHtml (String source, Html. ImageGetter imageGetter, Html. TagHandler tagHandler)

Returns the displayed style text from the Html string.

Static String

ToHtml (Spanned text)

Convert text to Html.


Method description:

Public static Spanned fromHtml (String source, Html. ImageGetter imageGetter, Html. TagHandler tagHandler)

Parameters:

Source: a string containing Html.

ImageGetter: imageGetter object. When tags are parsed, the system calls the getDrawable method of the imageGetter object and passes the src attribute value to the getDrawable method. The specific meaning of the src attribute must be determined in the getDrawable method. The getDrawable method returns a Drawable object. We can obtain image resources from res/drawable resources, assets resources, SD cards, and networks and package them into Drawable objects.

TagHandler: The TagHandler object. The handleTag method of the object is called when the system does not process a tag. However, this parameter is not commonly used. If not, you can set it to null.

To be continued ......

Related Article

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.