Code example for SpannableStringBuilder

Methods: getSpans, length

0
        assertEquals(1, spans.length);
        assertEquals(50, spans[0].getForegroundColor());
    } 
 
    private void checkLinks(final SpannableStringBuilder builder) {
        final URLSpan[] spans = builder.getSpans(0, builder.length(), URLSpan.class);
 
        assertNotNull(spans);
        assertEquals(1, spans.length);
        assertEquals("http://kouchat.googlecode.com/", spans[0].getURL());
    } 
 
    private void checkSmileys(final SpannableStringBuilder builder) {
        final ImageSpan[] spans = builder.getSpans(0, builder.length(), ImageSpan.class);
 
        assertNotNull(spans);
        assertEquals(1, spans.length);
        assertEquals(":)", spans[0].getSource());
        assertEquals(R.drawable.ic_smiley_smile, smileyId(spans[0].getDrawable()));
    }