You are using R.color.blue
which returns the id
. You should instead get the color as follows:
getResources().getColor(R.color.blue)
so it will be:
spannable.setSpan(new ForegroundColorSpan(isBlue ? getResources().getColor(R.color.blue): getResources().getColor(R.color.pink)),
spannable.length() - 1,
spannable.length(),
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
The reason it is gray is because the value of R.color.blue
(the id
value) maybe an integer corresponding to the color gray.