I want to use a code that indicates the color of the button (id=button1) and do something if the color is blue, I mean =
if the color of button1 is blue type 1, if its green,yellow or other color, type game over.
how can i do it?
i tried this way:
if(v.getId() == R.id.button1){
ColorDrawable buttonColor = (ColorDrawable) button1.getBackground();
int colorId = buttonColor.getColor();
}
there is an error:
Multiple markers at this line
- Type mismatch: cannot convert from ColorDrawable to int
- The method getColor() is undefined for the type
and if you are hovering over the getColor() you get another error:
The method getColor() is undefined for the type ColorDrawable
what can I do? thx.