android – How do I convert a color field to an int value correctly with JSON?


I get a field in this format:


I need to change the background color of a view , but setBackground wants an int .

Question: Is there a function for this or to manually write to convert to the decimal system?


int color = Color.parseColor(String color);

Link to the office. documentation

P. C, you need not from JSON, but from a string, because you must first get the string "percent_home_color":"#65ff65" from JSON

Scroll to Top