Java tutorial
//package com.java2s; //License from project: Open Source License import android.text.Editable; import android.text.Spanned; public class Main { /** * Modified from {@link android.text.Html} */ private static void end(Editable text, Class<?> kind, Object... replaces) { int len = text.length(); Object obj = getLast(text, kind); int where = text.getSpanStart(obj); text.removeSpan(obj); if (where != len) { for (Object replace : replaces) { text.setSpan(replace, where, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } } /** * @see android.text.Html */ private static Object getLast(Spanned text, Class<?> kind) { /* * This knows that the last returned object from getSpans() * will be the most recently added. */ Object[] objs = text.getSpans(0, text.length(), kind); if (objs.length == 0) { return null; } return objs[objs.length - 1]; } }