I am trying to convert the "Black" to string but I am not getting it
colorList.add(new ColorView("Black", "#000000"));
2
Not sure of your expectations here. But if you need to use the color black as color in your code you can directly use it like below:
String color = "Black";
There’s no need to convert.
If you want to convert any RGB color to hexadecimal value,then your can try below code snippet
Color yourColor = new Color(0,0,0); String hex = "#" + Integer.toHexString(yourColor.getRGB()).substring(2);
If you just want to convert some specified color,then Color has many built in color constant, we can try below code snippet
String hex = "#" + Integer.toHexString(Color.BLACK.getRGB()).substring(2);
Click here to cancel reply.
2
Answers
Not sure of your expectations here. But if you need to use the color black as color in your code you can directly use it like below:
There’s no need to convert.
If you want to convert any RGB color to hexadecimal value,then your can try below code snippet
If you just want to convert some specified color,then Color has many built in color constant, we can try below code snippet