Ideas:
1.gallery Internal Control mount events (such as: Onclicklistener) are similar to the ListView, which can be mounted directly within the Baseadapter.getview (detailed method Baidu).
2. It seems to be no problem, but it is not true that the event is triggered when you lift your finger after sliding (finger on the control that mounts the event).
Workaround, if you are sliding (x has an offset), the event is intercepted in Gallery.onintercepttouchevent, and the child control naturally accepts no events.
Note:1> can not simply infer that X has an offset to intercept, some devices are cheap, even if the position is raised there may be offset, this should trigger the onclick is also intercepted.
Therefore, to be compatible with most machines, you need to move horizontally beyond a certain threshold to intercept.
So within the threshold range, the gallery is not moving.
3. The problem comes again, when you slowly slide the 2nd item, you will find that the "child" has a distinct mutation (x-coordinate mutation).
The basic reason is that the gallery starts to move normally when it appears that the sliding exceeds the threshold, and in fact the gallery also does some initialization when the hand starts moving (gallery is not yet moved), causing an error when the gallery really moves.
Workaround, when you swipe your finger within the threshold, you keep doing this initialization so that when the gallery really starts moving, there is no error in initialization.
public class Mygallery extends Gallery {float Mlastmotionx = 0;public mygallery (context context) {super (context);//TODO A Uto-generated Constructor Stub}public Mygallery (context context, AttributeSet attrs, int defstyle) {Super (context, attrs , defstyle);//TODO auto-generated Constructor Stub}public mygallery (context context, AttributeSet Attrs) {Super (context , attrs);//TODO auto-generated constructor stub} @Overridepublic boolean onintercepttouchevent (motionevent ev) {final int action = Ev.getaction (); final float x = ev.getx (); switch (action) {case MotionEvent.ACTION_MOVE:final int xdiff = (int ) Math.Abs (X-mlastmotionx); if (Xdiff >50) {return true;} Break;case MotionEvent.ACTION_DOWN:mLastMotionX = x;//A mutation ontouchevent (EV) occurs when the "2nd item" is prevented from sliding; return false;}}
"Android" to the gallery inside " controls " Mount events, swipe to lift the finger when the event is also triggered (should not be triggered when sliding) to resolve,!