android 搜索自动匹配关键字并设置器颜色

 SpannableString s = new SpannableString(item.getString);
        LogUtil.E("keyword:"+keyWord);
        Pattern p = Pattern.compile(keyWord);
        Matcher m = p.matcher(s);
        while (m.find()) {
            int start = m.start();
            int end = m.end();
            s.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.c_3da3ff)), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

你可能感兴趣的:(android)