I am trying to create an Android App in which I want to change my button color when I clicked and that color should be change until I press again.
For Example
On first click color should be red and on click again it should converts to green, it should remain red until I click again.
3
Answers
by default it will be grey but after click on button it will change to orage until press any other button it will remain same (orange) Create two colors resource files in drawable and use them as background like I did. And then use this code in OnClick of button.
In kotlin you can do like this using flag to keep track of color
You can just do a switch by getting the color. Put in your
OnClickListener
something like