Ideas:
1.gallery Internal Control mount events (such as: Onclicklistener) are similar to the ListView method, which can be mounted directly within the Baseadapter.getview (specific method Baidu).
2. It doesn't seem to be a problem, but it is not right to trigger the event when you lift your finger after sliding (the finger is on the control that is mounting 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 determine the x has an offset to intercept, some equipment to make a base, 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 seemingly sliding beyond the threshold, the gallery began to move normally, in fact, when the hand began to move (Gallery has not moved), gallery also did some initialization, resulting in gallery real movement error.
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;}}