Code example for SpannableString

Methods: toHtml

0
 
    @SmallTest 
    public void testEntities() throws Exception { 
        SpannableString s;
 
        s = new SpannableString("Hello <&> world");
        assertEquals(Html.toHtml(s), "<p>Hello &lt;&amp;&gt; world</p>\n");
 
        s = new SpannableString("Hello \u03D5 world");
        assertEquals(Html.toHtml(s), "<p>Hello &#981; world</p>\n");
 
        s = new SpannableString("Hello  world");
        assertEquals(Html.toHtml(s), "<p>Hello&nbsp; world</p>\n");
    } 
 
    @SmallTest 
    public void testMarkup() throws Exception { 
        SpannableString s;
 
        s = new SpannableString("Hello bold world");
        s.setSpan(new StyleSpan(Typeface.BOLD), 6, s.length() - 6,