I set the color to my colors.xml resource. This is great for TextViews, etc.
<color name="medsListItem">#980000</color>
I am creating some html / lines in the code and wanted to use the same colors as in my application and keep everything well organized.
I use the code below to get the color from the resource above
String colorToUse = (String) getResources (). getString (R.color.medsListItem);
line created - this is # ff980000 Android adds ff to my line in characters 2 and 3 (or replaces # # # before the line). I can get around this by adding another line to the code
colorToUse = "#" + colorToUse.substring (3, 9);
but I think that I have something missing (a) inelegant and (b) I don’t know why ff is added (guessing that this is due to how android handles the color value)
source
share