Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

Html

extends Object
java.lang.Object
   ↳ android.text.Html

Class Overview

This class processes HTML strings into displayable styled text. Not all HTML tags are supported.

Summary

Nested Classes
interface Html.ImageGetter Retrieves images for HTML <img> tags. 
interface Html.TagHandler Is notified when HTML tags are encountered that the parser does not know how to interpret. 
Public Methods
static String escapeHtml ( CharSequence text)
Returns an HTML escaped representation of the given plain text.
static Spanned fromHtml ( String source)
Returns displayable styled text from the provided HTML string.
static Spanned fromHtml ( String source, Html.ImageGetter imageGetter, Html.TagHandler tagHandler)
Returns displayable styled text from the provided HTML string.
static String toHtml ( Spanned text)
Returns an HTML representation of the provided Spanned text.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static String escapeHtml ( CharSequence text)

Returns an HTML escaped representation of the given plain text.

public static Spanned fromHtml ( String source)

Added in API level 1

Returns displayable styled text from the provided HTML string. Any <img> tags in the HTML will display as a generic replacement image which your program can then go through and replace with real images.

This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.

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

Added in API level 1

Returns displayable styled text from the provided HTML string. Any <img> tags in the HTML will use the specified ImageGetter to request a representation of the image (use null if you don't want this) and the specified TagHandler to handle unknown tags (specify null if you don't want this).

This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.

public static String toHtml ( Spanned text)

Added in API level 1

Returns an HTML representation of the provided Spanned text.