博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
TextView改变颜色
阅读量:6715 次
发布时间:2019-06-25

本文共 462 字,大约阅读时间需要 1 分钟。

 if(sr!=null){

      String str=childlist.get(groupPosition).get(childPosition).getTitle();
      int indexOf = str.indexOf(sr);
      if(indexOf != -1){
       
       int end = indexOf+sr.length();
       SpannableStringBuilder builder = new SpannableStringBuilder(str );
       ForegroundColorSpan redSpan = new ForegroundColorSpan(Color.RED);
       builder.setSpan(redSpan, indexOf, end, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); 
       itemtitle.setText(builder);
      }

转载于:https://www.cnblogs.com/liuliwei123456/p/5158701.html

你可能感兴趣的文章