【发布时间】:2016-09-02 22:22:31
【问题描述】:
我有一个字符串
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 原始灰色到蓝色。 上面的代码什么也没做。我做错了什么。
【问题讨论】:
标签: java android eclipse android-studio