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