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 ();
}
}