Binding button style to a variable android -
i have variable in app symbolizes state..
i want button's ui change, regarding value of variable.
for example:
variable = 1 --> button = green
variable = 2 --> button = red
i know there xml file can change ui based on clicking, don't think handles scenario
thanks :)
try this..
private void buttonbgbasedonvariable(int variable){ if(variable == 1){ button.setbackgroundcolor(color.green); }else if(variable == 2){ button.setbackgroundcolor(color.red); } }
Comments
Post a Comment