Android Event Distribution notes

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.