android括号内文字修改颜色 数据后台返回
作者:互联网
String name = payChannelListDTO.getName();
String subNameA = name.substring(0, name.indexOf("(")+1);
String subNameB = name.substring(name.indexOf(")"));
String quStr=name.substring(name.indexOf("(")+1,name.indexOf(")"));
String replace = subNameB.replace("\\n", "\n");//遇到\n换行(可不加)
SpannableString ss = new SpannableString(quStr);
ForegroundColorSpan span = new ForegroundColorSpan(Color.RED);
ss.setSpan(span, 0, quStr.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
标签:name,indexOf,substring,括号,quStr,后台,android,ss,String 来源: https://blog.csdn.net/chenxchhh/article/details/123040415