in java i have
color_value="FFAAFF";
I have tried:
int color = Integer.parseInt(color_value);`
How can I convert it to int(hex) to add to im_view.setBackgroundColor(int color);
?
in java i have
color_value="FFAAFF";
I have tried:
int color = Integer.parseInt(color_value);`
How can I convert it to int(hex) to add to im_view.setBackgroundColor(int color);
?
As we have to guess the lang you're using, i'll assume it's java, what you actually need is to convert from HEX to RGB, if you are comfortable with AWT then you could use a built in func:
String color_value = "FFAAFF";
im_view.setBackgroundColor(Color.decode(color_value));
If don't want to use AWT, then you could do it like this:
/**
*
* @param colorStr e.g. "#FFFFFF"
* @return
*/
public static Color hex2Rgb(String colorStr) {
return new Color(
Integer.valueOf( colorStr.substring( 1, 3 ), 16 ),
Integer.valueOf( colorStr.substring( 3, 5 ), 16 ),
Integer.valueOf( colorStr.substring( 5, 7 ), 16 ) );
}
im_view.setBackgroundColor(hex2Rgb(color_value));