安卓中关键字变色

SpannableString s = new SpannableString(list.get(groupPosition).getList().get(childPosition).getTitle());
Pattern p = Pattern.compile(et_content);
Matcher m = p.matcher(s);
while (m.find()) {
int start = m.start();
int end = m.end();
s.setSpan(new ForegroundColorSpan(Color.RED), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
child_title.setText(s);

猜你喜欢

转载自blog.csdn.net/qq_33983391/article/details/51382020