0

I am getting a number from response which I append that in TextView. Now I need to change the color of the specific number declared in colors.xml. But I am clueless how to change the specific number alone by applying the color.

For eg: text color has black and number color has blue.

 retailerCount.setText("Performance of "+seProfile.getTotRetailerCnt()+ " retailers in Route Plan");
//retailerCount.setTextColor(getColor(R.color.colorAccent));//this applies entirely.

seProfile.getTotRetailerCnt is where it displays number as 15 from the response.

So output will be Performance of 15 retailers in Route Plan. So in this, I need to apply blue color for 15 and black color for other text.

Pavneet_Singh
  • 36,884
  • 5
  • 53
  • 68
Walter
  • 189
  • 2
  • 16

1 Answers1

0

Try this:

retailerCount.setText(Html.fromHtml("<font color=\"#000000\">" +"Performance of "+ "</font>" + "<font color=\"#0000FF\">" +seProfile.getTotRetailerCnt() + "</font>"+"<font color=\"#000000\">"+" retailers in Route Plan"+"</font>"));

I may missed Font open or close check it out by running

Ashwini Bhat
  • 500
  • 1
  • 4
  • 17