我有一个字符串
1 Friend | O Reviews | 0 Coupons
我正在使用以下代码
SpannableString hashText = new SpannableString(TextUtils.concat(
friendsText,
" | ",
reviewsText,
" | ",
couponsText
).toString());
Matcher matcher = Pattern.compile("\\s* | \\s*").matcher(hashText);
while (matcher.find())
{
hashText.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.blue)), matcher.start(), matcher.end(), 0);
}
detailsText.setText(hashText);
我想要将TextView中的“|”颜色从原来的灰色改为蓝色。 上述代码并没有起到作用。我做错了什么?