直接从项目里copy来,就没做精修了,应该看得懂哈
//检索文字
String searchText = edit.getText().toString();
//从后台拉下来的检索内容
String showText = shopApplyBeanList.get(position).getTitle();
//包含检索文字的start end 下标
int start = showText.indexOf(searchText);
int end = start + searchText.length();
SpannableStringBuilder builder = new SpannableStringBuilder(showText);
builder.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.theme)), start, end, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
holder.businessName.setText(builder);
holder.count.setText(getString(R.string.approx) + shopApplyBeanList.get(position).getCount() + getString(R.string.posts));
TextView 修改中间文字颜色
最新推荐文章于 2023-10-12 15:29:03 发布