text = text + CepVizyon.getPhoneCode() + "\n\n"
+ getText(R.string.currentversion) + CepVizyon.getLicenseText();
activationText.setText(text);
myTextView.setText(text);
I want to change color for CepVizyon.getPhoneCode()
's string. How can I do this?
I did as andy boot said, but i had a clickable span as well, and it didn't work because the order the
setSpans
were called. So you have to first call thespannable.setSpan(clickableSpanand...
then thespannable.setSpan(new ForegroundColorSpan...
to get the color in the TextViewIt is good for me!
Here's a
colorize
function based on andyboot's answer:If you have static text that needs color, you can add it without any code via the strings file:
then
result
not sure which api versions this works on, but doesnt work for api 19 that ive tested so far, so probably only some of the most recent api versions support this
edit: as @hairraisin mentioned in the comments, try using
fgcolor
instead ofcolor
for the font color, then it should work for lower api levels, but need more testing to be sureWith regards to Maneesh's answer, this will work but you need to add and escape the quotes for the color attribute.
Spannable is more flexible: