Here you can find the source of highlight(int start, int end, TextView text)
Parameter | Description |
---|---|
start | a parameter |
end | a parameter |
text | a parameter |
public static void highlight(int start, int end, TextView text)
//package com.java2s; import android.graphics.Color; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import android.widget.TextView; public class Main { /**/* w ww . j a v a2 s. co m*/ * hightlight text * @param start * @param end * @param text */ public static void highlight(int start, int end, TextView text) { SpannableStringBuilder spannable = new SpannableStringBuilder(text .getText().toString()); ForegroundColorSpan span = new ForegroundColorSpan(Color.RED); spannable.setSpan(span, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); text.setText(spannable); } }