44

setBackgroundColor() only takes ints. I don't really know what int equals to what color. Is there a simple way to convert a string like #2222FF on runtime into an int?

0

1 Answer 1

118
int color = Color.parseColor("#2222FF");
Sign up to request clarification or add additional context in comments.

2 Comments

But it is giving me a value like -14540033, i mean minus value, so is it true?
@PareshMayani uh, why do you expect it to be positive? It's o.k. I guess.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.