Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Spannable and String in android

Curiously want to know what is the purpose of Spannable in android. Isn't char array sufficient?

like image 480
DraD Avatar asked Feb 19 '13 07:02

DraD


1 Answers

A Spannable allows to attach formatting information like bold, italic, ... to sub-sequences ("spans", thus the name) of the characters. It can be used whenever you want to represent "rich text".

The Html class provides an easy way to construct such text, for example:

Html.fromHtml("Text with <b>bold</b> and <em>italic</em>.")
like image 76
Henry Avatar answered Oct 03 '22 07:10

Henry