Code example for URLSpan

0
 
            if (where != len) {
            	CharSequence bus = output.subSequence(where, len);
            	String url = getBusUrl(bus);
            	Log.d(TAG, "Adding bus url: " + url);
                output.setSpan(new URLSpan(url), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            } 
        } 
	} 
 
	private <T> T getLast(Editable text, Class<T> kind) {
        T[] objs = text.getSpans(0, text.length(), kind);
 
        if (objs.length == 0) {
            return null; 
        } else { 
            for(int i = objs.length;i>0;i--) {
                if(text.getSpanFlags(objs[i-1]) == Spannable.SPAN_MARK_MARK) {
                    return objs[i-1];
                } 
            }