Android to achieve button click effect
1. First create a button
2. BTN is used in the background of the button created in 1_ St, create BTN under drawable_ st
3. Color1 and color2 used in 2 are added to the strings of values
4. Java code
(1) Get the button first
Button clickbtn = (Button) findViewById(R.id.click);
(2) Set a flag
int flag = 0;
(3) Add listening event to button
Idea: set active / inactive two different colors for the button. When the button is clicked once or three times, the button is set to inactive state (pressed), and when the button is clicked even times, it is set to active state (not pressed).
The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!