Gallery implementation of quick drag only one page Solution

Source: Internet
Author: User
Zookeeper

Gallery is rarely used this year. This article provides a method to slide only to the next page at a time (including fast sliding ).


Import Android. content. context;
Import Android. util. attributeset;
Import Android. View. keyevent;
Import Android. View. motionevent;
Import Android. widget. Gallery;

Public class recommendgallery extends gallery {

Public recommendgallery (context ){
Super (context );
}

Public recommendgallery (context, attributeset attrs ){
Super (context, attrs );
}

@ Override
Public Boolean onfling (motionevent E1, motionevent E2, float velocityx,
Float velocityy ){
// Todo auto-generated method stub
Int kevent;
If (isscrollingleft (E1, E2) {// check if scrolling left
Kevent = keyevent. keycode_dpad_left;
}
Else {// otherwise scrolling right
Kevent = keyevent. keycode_dpad_right;
}
Onkeydown (kevent, null );
Return true;

}
Private Boolean isscrollingleft (motionevent E1, motionevent E2 ){
Return e2.getx ()> e1.getx ();
}
}

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.