Android examples for android.text:SpannableString
create Link Text via SpannableString
import android.text.SpannableString; import android.text.Spanned; import android.text.style.URLSpan; public class Main { public static SpannableString createLinkText(String text, String clickText, String url) { if (!text.contains(clickText)) { return null; }// w w w.j a v a 2 s . co m SpannableString sp = new SpannableString(text); int index = text.indexOf(clickText); sp.setSpan(new URLSpan(url), index, index + clickText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return sp; } }