Code example for Spanned

Methods: getSpanslengthtoString

        builder.setSpan(new CustomSpan(), 4, builder.length(), 0);
    private void checkPostProcess(Spanned ret) {
        // Newlines should be trimmed. 
        assertEquals("01234", ret.toString());
        // First, check the image span. 
        // - Vertical alignment should be changed to ALIGN_BASELINE 
        // - Drawable shouldn't be changed. 
        ImageSpan[] imageSpans = ret.getSpans(0, ret.length(), ImageSpan.class);
        assertEquals(1, imageSpans.length);
        assertEquals(ImageSpan.ALIGN_BASELINE, imageSpans[0].getVerticalAlignment());
        assertEquals(ColorDrawable.class, imageSpans[0].getDrawable().getClass());
        // QuoteSpans should be replaced with StreamItemQuoteSpans. 
        QuoteSpan[] quoteSpans = ret.getSpans(0, ret.length(), QuoteSpan.class);
        assertEquals(1, quoteSpans.length);
        assertEquals(StreamItemQuoteSpan.class, quoteSpans[0].getClass());
        // Other spans should be preserved. 
        CustomSpan[] customSpans = ret.getSpans(0, ret.length(), CustomSpan.class);
        assertEquals(1, customSpans.length);
    /** Custom span class used in {@link #testPostProcess} */ 
    private static class CustomSpan {