# Setting the background of my textView as a color from 3 integers

public void changeColor(){ TextView changeColorText = (TextView) findViewById(R.id.textView2); changeColorText.setBackgroundColor(0xFFFF0000); }

My goal here is to take 3 integers and make them into a color. I see that its put into hexadecimal number and the one that I have outputs red. So does this mean with the three integers that I have, i have to convert them into hex? If so how would i convert decimal into hex? Ive researched a few ways to do this, but none of them seem to be what i'm looking for. I have 3 integers so far that only go up to 255, which i assume is correct. Is there an equation that I am missing?

## Answers

the three integers that you have are the RGB (Red Green Blue) i presume. Since they go unto 255. Try this

changeColorText.setBackgroundColor(Color.rgb(255,0,255)); //sets the color to purple

- Red 255
- Green 0
- Blue 255

You should be able to set the background with RGB. Try something like this :

changeColorText.setBackgroundColor(Color.rgb(r, g, b));

Where r g and b are your color values (red, green, and blue). I'm assuming the number's your pulling are RGB values as each one is a set number between 0-255