1.Simpleongesturelistener
Problems encountered:
You define a button that inherits from the button, and the action that starts with changing the color of the buttons is triggered in the Ontouchevent Ation_down.
At this point, put in the scrollview inside, found that if the button to slide, will trigger the button to change the color, obviously this is wrong.
Then I checked and found Simpleongesturelistener.
Rewritten the Ondown event and the Onsingletapup event, the code is as follows
PrivateSimpleongesturelistener Msimpleongesturelistener =NewSimpleongesturelistener () {@Override Public BooleanOnsingletapup (motionevent e) {//change the color only when the click, if in the Ondown, the swipe will also change the colorSetchecked (!mischecked); return true; } @Override Public BooleanOndown (motionevent e) {//This returns true before calling Onsingletapup return true; } };
Rewrite the ontouchevent in your custom button
@Override Public Boolean ontouchevent (Motionevent event) { return mgesturedetector.ontouchevent (event);}
QUOTE
1. Click on the execution of an item on the screen there are two cases, one is short time, one time is slightly longer
Time is short: Ondown--------"Onsingletapup--------" onsingletapconfirmed
A little longer: Ondown--------"onshowpress------" Onsingletapup--------"onsingletapconfirmed
2. Long Press Events
Ondown--------"onshowpress------" onlongpress
3. Toss: After the finger touches the screen, slightly swipe and release immediately
Ondown-----"onscroll----" onscroll----"onscroll----" ...----->onfling
4. Drag
Ondown------"onscroll----" onscroll------"onfiling
Note: Sometimes it triggers onfiling, but sometimes it does not trigger, and personal understanding is caused by the non-standard movement of people.
Android Event Distribution notes