java - Android studio setting a hex color value for a button with code -
i change button color on click, have used following code button.setbackgroundcolor(#ff512e);
did not work. have googled , couldn't find answer. i'm aware change in xml code need changed once button clicked. have set listeners , else needed need code set button color hex value on click.
setbackgroundcolor(int) method takes integer argument passing string in code.
use instead parse hex code of color int:
button.setbackgroundcolor(color.parsecolor("#ff512e"));
Comments
Post a Comment