ashik94vc / ElegantNumberButton

Widget which acts as a number counter which changes its number on +/- press.
Apache License 2.0
180 stars 62 forks source link

No Background Color change Dynamically #20

Closed RishabhRawatAndroid closed 6 years ago

RishabhRawatAndroid commented 6 years ago

I am creating an app which I use this library for adding the cart item but the problem is button colour not change in dynamically. I use this code but not change the color

numberButton.setOnValueChangeListener(new ElegantNumberButton.OnValueChangeListener() {
                @Override
                public void onValueChange(ElegantNumberButton view, int oldValue, int newValue) {
                    if(newValue!=0)
                        numberButton.setBackgroundColor(getResources().getColor(R.color.lime_green));
                    else
                        numberButton.setBackgroundColor(getResources().getColor(R.color.yellow));
                }
            });
RishabhRawatAndroid commented 6 years ago

I notice that your code has a method updateColors but this method is not available in 1.0.2 version library.

 public void updateColors(int backgroundColor, int textColor) {
        this.textView.setBackgroundColor(backgroundColor);
        this.addBtn.setBackgroundColor(backgroundColor);
        this.subtractBtn.setBackgroundColor(backgroundColor);

        this.textView.setTextColor(textColor);
        this.addBtn.setTextColor(textColor);
        this.subtractBtn.setTextColor(textColor);
    }