I am writing a program with only one button. At beginning, the button is in default color; when clicking on the button, it’s background color turns to red, and then clicking once more, its background color turns to it’s default color. Any suggestion on writing a code in myButton.setOnClickListener(new OnClickListener(){} method? Thanks
I am writing a program with only one button. At beginning, the button is
Share
You can definitely improve the logic to be more readable.
Also you can simply use ToggleButton, which has two states. Each state has its own background drawable/color which you can specify in xml file. No need of listener.