Gallery Judge Scroll start and stop

Source: Internet
Author: User

To do some processing when the gallery starts sliding and at the end of the slide, you need to know the timing of the start and stop of the slide.

1. The time to start

Gallery Mcoverflowview = new Gallery (context);

Final Gesturedetectorcompat Mgesturedetectorcompat = new Gesturedetectorcompat (this, this);

Mcoverflowview.setontouchlistener (New Ontouchlistener () {

@Override

public boolean OnTouch (View V, motionevent event) {

Return Mgesturedetectorcompat.ontouchevent (event);

}

});

  

});

The Ongesturelistener can then be used in the

@Override

public boolean onscroll (Motionevent E1, motionevent E2, float Distancex,

Float Distancey) {

Adding processing logic at start of slide

return false;

}

2. Determine when gallery stops

Mcoverflowview.setcallbackduringfling (FALSE);

Mcoverflowview.setonitemselectedlistener (New Onitemselectedlistener () {

@Override

public void onitemselected (adapterview<?> parent, view view,

int position, long ID) {

Add sliding end processing logic

}

@Override

public void onnothingselected (adapterview<?> parent) {

}

});

Gallery Judge Scroll start and stop

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.