Code example for Spanned

Methods: getSpanslength

    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,
Stop searching for code, let great code find you!  Add Codota to your java IDE