Code example for ColorDrawable

Methods: getColor

0
                    @Override 
                    public void onClick(View view) {
         
                        ColorDrawable color = (ColorDrawable) view.getBackground();
         
                        int backgroundColor = color.getColor();
         
                        if(backgroundColor == Color.GREEN) {
                            view.setBackgroundColor(Color.YELLOW);
                            showToast("Running late?"); 
         
                        } 
         
                        if(backgroundColor == Color.YELLOW) {
                            view.setBackgroundColor(Color.RED);
                            view.setVisibility(View.GONE);
                            showToast("Can't make it"); 
                        } 
         
                        if(backgroundColor == Color.RED) {
Experience pair programming with AI  Get Codota for Java