Code example for Spanned

Methods: getSpans, length

0
    private static <T> T getLast(Spanned text, Class<T> kind) {
        /* 
         * This knows that the last returned object from getSpans() 
         * will be the most recently added. 
         */ 
        T[] objs = text.getSpans(0, text.length(), kind);
 
        if (objs.length == 0) {
            return null; 
        } else { 
            return objs[objs.length - 1];
        } 
    } 
 
    private static void start(SpannableStringBuilder text, Object mark) {
        int len = text.length();
        text.setSpan(mark, len, len, Spannable.SPAN_MARK_MARK);
    } 
 
    private static <T> void end(SpannableStringBuilder text, Class<T> kind,
                            Object repl) {