You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`
public CharSequence buildSpannableStringBackground(CharSequence content, CharSequence keyword) {
if (TextUtils.isEmpty(content)) {
return new SpannableStringBuilder("");
}
if (TextUtils.isEmpty(keyword)) {
return content;
}
SpannableStringBuilder spannableString = new SpannableStringBuilder(content);
String lowerContent = content.toString().toLowerCase();
String lowerKeyword = keyword.toString().toLowerCase();
int index = lowerContent.indexOf(lowerKeyword);
if (index != -1) {
int color = getApplicationContext().getResources().getColor(R.color.yc_color_FFFA00);
while (index != -1) {
spannableString.setSpan(new BackgroundColorSpan(color), index, index + lowerKeyword.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
index = lowerContent.indexOf(lowerKeyword, index + 1);//从这个索引往后开始第一个出现的位置
}
}
return spannableString;
}
use system can set BackgroundColorSpan(),but no working on self.What is the solution.
The text was updated successfully, but these errors were encountered: