Code example for SpannableStringBuilder

Methods: getSpanStart, length, removeSpan, setSpan

0
            _builder.setSpan(repl, where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } 
     
    private void endLastSpan() 
    { 
        int len = _builder.length();
        Object obj = getLast(_builder, Span.class);
        int where = _builder.getSpanStart(obj);
         
        _builder.removeSpan(obj);
         
        if (where != len)
        { 
            Object span = null;
             
            if (obj instanceof Bold)
                span = new StyleSpan(Typeface.BOLD);
            else if (obj instanceof Italic)
                span = new StyleSpan(Typeface.ITALIC);
            else if (obj instanceof Blockquote)
                span = new TypefaceSpan("serif");
            else if (obj instanceof Underline)
                span = new UnderlineSpan();
            else if (obj instanceof Strikethrough)
                span = new StrikethroughSpan();
            else if (obj instanceof Spoiler)
                span = new SpoilerSpan(_owner);
            else if (obj instanceof Sample)
                span = new RelativeSizeSpan((float)0.80);
            else if (obj instanceof Code)
                span = new TypefaceSpan("monospace");
            else if (obj instanceof Font && _showTags)
                span = new ForegroundColorSpan(getColor(((Font)obj).getColor()) | 0xFF000000);
             
            if (span != null)
                _builder.setSpan(span, where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        } 
    } 
 
    public void characters(char[] ch, int start, int length) throws SAXException
    {