Code example for SpannableStringBuilder

Methods: getSpanStart, getSpans, length, removeSpan, setSpan

0
            text.append("\n");
    } 
     
    private Object getLast(Spanned text, Class<?> kind)
    { 
        Object[] objs = _builder.getSpans(0, _builder.length(), kind);
         
        if (objs.length == 0)
            return null; 
        return objs[objs.length -1];
    } 
     
    private void start(Object mark)
    { 
        int len = _builder.length();
        _builder.setSpan(mark, len, len, Spannable.SPAN_MARK_MARK);
    } 
     
    private void startA(Attributes attributes)
    { 
        String href = attributes.getValue("", "href");
         
        int len = _builder.length();
        _builder.setSpan(new Href(href), len, len, Spannable.SPAN_MARK_MARK);
    } 
     
    private void endA() 
    { 
        int len = _builder.length();
        Object obj = getLast(_builder, Href.class);
        int where = _builder.getSpanStart(obj);
         
        _builder.removeSpan(obj);
         
        if (where != len)
        { 
            Href h = (Href)obj;
             
            if (h.getHref() != null)
            { 
                _builder.setSpan(new URLSpan(h.getHref()), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            } 
        } 
    } 
     
    private void end(Class<?> kind, Object repl)