标签:
上一篇,我们从源码的角度分析了View的事件分发过程,这篇我们从实例的角度来看看不同实例下具体的输出会是什么样子的呢?好的,我们开始吧!
同样我们的测试布局文件:
<com.hzw.eventtest.MyRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/myRelativeLayout" android:layout_width="match_parent" android:layout_height="match_parent" > <com.hzw.eventtest.MyButton android:id="@+id/myButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我的按钮" /> </com.hzw.eventtest.MyRelativeLayout>也即我们的测试布局是酱紫的:
注意直接运行测试代码的效果我在上一篇博客中已经贴出来了,这一篇将不再涉及;
测试1:(仅仅将MyButton的onTouch方法的返回值修改为true)
也就是修改MyButton的setOnTouchListener参数的onTouch方法返回值;
长按MyButton按钮查看Logcat输出:
07-01 02:19:16.867: I/System.out(776): MainActivity--->dispatchTouchEvent--->ACTION_DOWN 07-01 02:19:16.870: I/System.out(776): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN 07-01 02:19:16.870: I/System.out(776): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN 07-01 02:19:16.870: I/System.out(776): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN--->false 07-01 02:19:16.870: I/System.out(776): MyButton--->dispatchTouchEvent--->ACTION_DOWN 07-01 02:19:16.880: I/System.out(776): MyButton--->onTouch--->DOWN 07-01 02:19:16.880: I/System.out(776): MyButton--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 02:19:16.880: I/System.out(776): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 02:19:16.880: I/System.out(776): MainActivity--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 02:19:16.963: I/System.out(776): MainActivity--->dispatchTouchEvent--->ACTION_UP 07-01 02:19:16.963: I/System.out(776): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP 07-01 02:19:16.963: I/System.out(776): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP 07-01 02:19:16.963: I/System.out(776): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP--->false 07-01 02:19:16.963: I/System.out(776): MyButton--->dispatchTouchEvent--->ACTION_UP 07-01 02:19:16.963: I/System.out(776): MyButton--->onTouch--->UP 07-01 02:19:16.970: I/System.out(776): MyButton--->dispatchTouchEvent--->ACTION_UP--->true 07-01 02:19:16.970: I/System.out(776): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP--->true 07-01 02:19:16.970: I/System.out(776): MainActivity--->dispatchTouchEvent--->ACTION_UP--->true
可以看到Log输出的第5行执行MyButton的dispatchTouchEvent之后,首先执行的是onTouch方法,因为我们在onTouch方法中返回了true,那么根据View事件分发源码分析知道dispatchTouchEvent将直接返回true,也就看到了onTouch之后直接输出的是第7行MyButton的dispatchTouchEvenet返回值,因为连onTouchEvent方法都没有执行,那么在onTouchEvent中的检测是否要执行onLongClick以及onClick也就不会执行了,随后的MOVE以及UP事件执行过程和DOWN事件一致,从这点看出来onTouch方法优先于onTouchEvent执行;
测试2:(仅仅将MyButton的onLongClick方法返回值设置为true)
也即仅仅修改MyButton的setOnLongClick参数的onLongClick返回值为true
长按MyButton按钮,查看Logcat输出:
07-01 04:42:08.118: I/System.out(1055): MainActivity--->dispatchTouchEvent--->ACTION_DOWN 07-01 04:42:08.120: I/System.out(1055): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN 07-01 04:42:08.120: I/System.out(1055): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN 07-01 04:42:08.120: I/System.out(1055): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN--->false 07-01 04:42:08.120: I/System.out(1055): MyButton--->dispatchTouchEvent--->ACTION_DOWN 07-01 04:42:08.120: I/System.out(1055): MyButton--->onTouch--->DOWN 07-01 04:42:08.120: I/System.out(1055): MyButton--->onTouchEvent--->ACTION_DOWN 07-01 04:42:08.120: I/System.out(1055): MyButton--->onTouchEvent--->ACTION_DOWN--->true 07-01 04:42:08.120: I/System.out(1055): MyButton--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 04:42:08.120: I/System.out(1055): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 04:42:08.120: I/System.out(1055): MainActivity--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 04:42:08.653: I/System.out(1055): MyButton--->onLongClick 07-01 04:42:08.950: I/System.out(1055): MainActivity--->dispatchTouchEvent--->ACTION_UP 07-01 04:42:08.950: I/System.out(1055): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP 07-01 04:42:08.950: I/System.out(1055): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP 07-01 04:42:08.950: I/System.out(1055): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP--->false 07-01 04:42:08.950: I/System.out(1055): MyButton--->dispatchTouchEvent--->ACTION_UP 07-01 04:42:08.960: I/System.out(1055): MyButton--->onTouch--->UP 07-01 04:42:08.960: I/System.out(1055): MyButton--->onTouchEvent--->ACTION_UP 07-01 04:42:08.960: I/System.out(1055): MyButton--->onTouchEvent--->ACTION_UP--->true 07-01 04:42:08.960: I/System.out(1055): MyButton--->dispatchTouchEvent--->ACTION_UP--->true 07-01 04:42:08.960: I/System.out(1055): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP--->true 07-01 04:42:08.970: I/System.out(1055): MainActivity--->dispatchTouchEvent--->ACTION_UP--->true前6行的输出和测试1是一样的,从第7行开始执行的是MyButton的onTouchEvent方法,原因就是我们在onTouch中返回的是false,接着你在第12行看到调用了onLongClick方法,在上一篇博客已经解释了为什么onLongClick会在第9行MyButton的dispatchTouchEvent返回后执行,原因就是因为onLongClick方法是在子线程中执行的,什么时间执行不是确定的,但可以保证肯定是在onClick方法前执行的,如果你多次进行测试2的测试,你会发现onLonClick方法与MOVE事件的执行顺序是不确定的,从上面的Log输出中我们同样没看到onClick的输出,原因在于我们在onLongClick方法中返回了true,这也就说明一点onLongClick优先于onClick执行;
测试3:(假设我们仅仅让MyButton的onTouch方法在DOWN的情况下返回false,剩余情况下返回true,这个测试主要是为了验证onLongClick是在DOWN事件下进行监听的)
也就是我把MyButton的Touch事件监听器修改成下面这样子:
myButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { boolean result = false; switch (arg1.getAction()) { case MotionEvent.ACTION_DOWN: System.out.println("MyButton--->onTouch--->DOWN"); result = false; break; case MotionEvent.ACTION_MOVE: System.out.println("MyButton--->onTouch--->MOVE"); result = true; break; case MotionEvent.ACTION_UP: System.out.println("MyButton--->onTouch--->UP"); result = true; break; default: break; } return result; } });长按MyButton,查看Logcat,你会看到下面输出:
07-01 05:04:35.920: I/System.out(1239): MainActivity--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:04:35.920: I/System.out(1239): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:04:35.920: I/System.out(1239): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN 07-01 05:04:35.920: I/System.out(1239): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN--->false 07-01 05:04:35.920: I/System.out(1239): MyButton--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:04:35.920: I/System.out(1239): MyButton--->onTouch--->DOWN 07-01 05:04:35.920: I/System.out(1239): MyButton--->onTouchEvent--->ACTION_DOWN 07-01 05:04:35.930: I/System.out(1239): MyButton--->onTouchEvent--->ACTION_DOWN--->true 07-01 05:04:35.941: I/System.out(1239): MyButton--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:04:35.941: I/System.out(1239): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:04:35.941: I/System.out(1239): MainActivity--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:04:36.445: I/System.out(1239): MyButton--->onLongClick 07-01 05:04:36.991: I/System.out(1239): MainActivity--->dispatchTouchEvent--->ACTION_UP 07-01 05:04:36.991: I/System.out(1239): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP 07-01 05:04:36.991: I/System.out(1239): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP 07-01 05:04:37.000: I/System.out(1239): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP--->false 07-01 05:04:37.000: I/System.out(1239): MyButton--->dispatchTouchEvent--->ACTION_UP 07-01 05:04:37.000: I/System.out(1239): MyButton--->onTouch--->UP 07-01 05:04:37.000: I/System.out(1239): MyButton--->dispatchTouchEvent--->ACTION_UP--->true 07-01 05:04:37.000: I/System.out(1239): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP--->true 07-01 05:04:37.000: I/System.out(1239): MainActivity--->dispatchTouchEvent--->ACTION_UP--->true输出中你会发现第7行在DOWN事件情况下执行了MyButton的onTouchEvent方法,因为我们在DOWN情况下设置了onTouch返回值是false,随后你看到了onLongClick的输出,但是在输出中你不会看到在MOVE和UP情况下执行onTouchEvent方法,因为这两种情况下onTouch方法的返回值是true,从这个测试例子你会知道onLongClick的执行时机在DOWN的时候就开始了,至于你是在MOVE和UP之前或者之后执行这个不确定,但是肯定是在UP之后调用onClick之前执行的;
测试4:(仅仅让MyButton的onTouch方法在UP的情况下返回false,剩余情况下返回true,这个测试主要是为了验证onClick的执行不仅仅是只有UP事件就可以的,他还需要在DOWN事件)
也就是我把MyButton的Touch事件监听器修改成下面这样子:
myButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { boolean result = false; switch (arg1.getAction()) { case MotionEvent.ACTION_DOWN: System.out.println("MyButton--->onTouch--->DOWN"); result = true; break; case MotionEvent.ACTION_MOVE: System.out.println("MyButton--->onTouch--->MOVE"); result = true; break; case MotionEvent.ACTION_UP: System.out.println("MyButton--->onTouch--->UP"); result = false; break; default: break; } return result; } });长按MyButton,你会看到下面输出:
07-01 05:20:37.160: I/System.out(1398): MainActivity--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:20:37.160: I/System.out(1398): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:20:37.160: I/System.out(1398): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN 07-01 05:20:37.160: I/System.out(1398): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN--->false 07-01 05:20:37.160: I/System.out(1398): MyButton--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:20:37.160: I/System.out(1398): MyButton--->onTouch--->DOWN 07-01 05:20:37.160: I/System.out(1398): MyButton--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:20:37.160: I/System.out(1398): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:20:37.160: I/System.out(1398): MainActivity--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:20:38.610: I/System.out(1398): MainActivity--->dispatchTouchEvent--->ACTION_UP 07-01 05:20:38.610: I/System.out(1398): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP 07-01 05:20:38.610: I/System.out(1398): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP 07-01 05:20:38.610: I/System.out(1398): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP--->false 07-01 05:20:38.610: I/System.out(1398): MyButton--->dispatchTouchEvent--->ACTION_UP 07-01 05:20:38.610: I/System.out(1398): MyButton--->onTouch--->UP 07-01 05:20:38.620: I/System.out(1398): MyButton--->onTouchEvent--->ACTION_UP 07-01 05:20:38.620: I/System.out(1398): MyButton--->onTouchEvent--->ACTION_UP--->true 07-01 05:20:38.630: I/System.out(1398): MyButton--->dispatchTouchEvent--->ACTION_UP--->true 07-01 05:20:38.630: I/System.out(1398): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP--->true 07-01 05:20:38.630: I/System.out(1398): MainActivity--->dispatchTouchEvent--->ACTION_UP--->true无论你怎么按按钮都不再会出现onLongClick以及onClick输出的,原因在于我们是在MyButton的onTouchEvent的DOWN事件中监听longclick以及click的,但是只有longclick会在DOWN事件之后有权利执行他的onLongClick方法,click执行他的onClick方法只能是在UP事件之后才能开始的,我们MyButton的onTouch方法在DOWN事件情况下返回了true,那么这种情况下连onTouchEvent都不会执行,就别说是监听longclick以及click了;同样MOVE情况下也不会执行MyButton的onTouchEvent方法,因为我们在这种情况下也将onTouch方法的返回值设置成了true;
测试5:(让MyButton的onTouch方法在DOWN以及UP的情况下返回false,UP情况下返回true,这个测试主要是为了验证onLongClick和onClick的执行在你点击和移动没有超出按钮范围的情况下和MOVE事件关系不大)
也就是我把MyButton的Touch事件监听器修改成下面这样子:
myButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { boolean result = false; switch (arg1.getAction()) { case MotionEvent.ACTION_DOWN: System.out.println("MyButton--->onTouch--->DOWN"); result = false; break; case MotionEvent.ACTION_MOVE: System.out.println("MyButton--->onTouch--->MOVE"); result = true; break; case MotionEvent.ACTION_UP: System.out.println("MyButton--->onTouch--->UP"); result = false; break; default: break; } return result; } });点击或者长按或者在MyButton上移动不超过他范围,查看Logcat输出:
07-01 05:38:52.231: I/System.out(1553): MainActivity--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:38:52.231: I/System.out(1553): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:38:52.231: I/System.out(1553): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN 07-01 05:38:52.241: I/System.out(1553): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN--->false 07-01 05:38:52.241: I/System.out(1553): MyButton--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:38:52.241: I/System.out(1553): MyButton--->onTouch--->DOWN 07-01 05:38:52.241: I/System.out(1553): MyButton--->onTouchEvent--->ACTION_DOWN 07-01 05:38:52.251: I/System.out(1553): MyButton--->onTouchEvent--->ACTION_DOWN--->true 07-01 05:38:52.251: I/System.out(1553): MyButton--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:38:52.251: I/System.out(1553): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:38:52.261: I/System.out(1553): MainActivity--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:38:52.789: I/System.out(1553): MyButton--->onLongClick 07-01 05:38:53.688: I/System.out(1553): MainActivity--->dispatchTouchEvent--->ACTION_UP 07-01 05:38:53.688: I/System.out(1553): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP 07-01 05:38:53.691: I/System.out(1553): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP 07-01 05:38:53.691: I/System.out(1553): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP--->false 07-01 05:38:53.691: I/System.out(1553): MyButton--->dispatchTouchEvent--->ACTION_UP 07-01 05:38:53.691: I/System.out(1553): MyButton--->onTouch--->UP 07-01 05:38:53.691: I/System.out(1553): MyButton--->onTouchEvent--->ACTION_UP 07-01 05:38:53.691: I/System.out(1553): MyButton--->onTouchEvent--->ACTION_UP--->true 07-01 05:38:53.691: I/System.out(1553): MyButton--->dispatchTouchEvent--->ACTION_UP--->true 07-01 05:38:53.691: I/System.out(1553): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP--->true 07-01 05:38:53.691: I/System.out(1553): MainActivity--->dispatchTouchEvent--->ACTION_UP--->true 07-01 05:38:53.691: I/System.out(1553): MyButton--->OnClick你会看到这种情况下既有onLongClick输出又有onClick输出,并且在DOWN和UP的情况下都会调用MyButton的onTouchEvent方法,我这里没有贴出来MOVE情况下的输出,如果你自己测试的话会发现MOVE情况下是不会执行MyButton的onTouchEvent方法的,因为这种情况下onTouch的返回值是true;
测试6:(测试5已经说了只有在那种情况下MOVE事件对onLongClick以及onClick没有影响,原因就是我们在MOVE情况下MyButton的onTouch方法的返回值是true的,如果将这个返回值修改为false的话就会有影响了)
也就是我把MyButton的Touch事件监听器修改成下面这样子:
myButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { boolean result = false; switch (arg1.getAction()) { case MotionEvent.ACTION_DOWN: System.out.println("MyButton--->onTouch--->DOWN"); result = false; break; case MotionEvent.ACTION_MOVE: System.out.println("MyButton--->onTouch--->MOVE"); result = false; break; case MotionEvent.ACTION_UP: System.out.println("MyButton--->onTouch--->UP"); result = false; break; default: break; } return result; } });如果你长按着MyButton按钮并且快速移到MyButton范围外,你会看到类似的下面输出:
07-01 05:45:44.030: I/System.out(1620): MainActivity--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:45:44.030: I/System.out(1620): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:45:44.030: I/System.out(1620): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN 07-01 05:45:44.030: I/System.out(1620): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_DOWN--->false 07-01 05:45:44.030: I/System.out(1620): MyButton--->dispatchTouchEvent--->ACTION_DOWN 07-01 05:45:44.040: I/System.out(1620): MyButton--->onTouch--->DOWN 07-01 05:45:44.040: I/System.out(1620): MyButton--->onTouchEvent--->ACTION_DOWN 07-01 05:45:44.050: I/System.out(1620): MyButton--->onTouchEvent--->ACTION_DOWN--->true 07-01 05:45:44.050: I/System.out(1620): MyButton--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:45:44.050: I/System.out(1620): MyRelativeLayout--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:45:44.050: I/System.out(1620): MainActivity--->dispatchTouchEvent--->ACTION_DOWN--->true 07-01 05:45:44.135: I/System.out(1620): MainActivity--->dispatchTouchEvent--->ACTION_MOVE 07-01 05:45:44.135: I/System.out(1620): MyRelativeLayout--->dispatchTouchEvent--->ACTION_MOVE 07-01 05:45:44.135: I/System.out(1620): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_MOVE 07-01 05:45:44.135: I/System.out(1620): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_MOVE--->false 07-01 05:45:44.140: I/System.out(1620): MyButton--->dispatchTouchEvent--->ACTION_MOVE 07-01 05:45:44.140: I/System.out(1620): MyButton--->onTouch--->MOVE 07-01 05:45:44.140: I/System.out(1620): MyButton--->onTouchEvent--->ACTION_MOVE 07-01 05:45:44.140: I/System.out(1620): MyButton--->onTouchEvent--->ACTION_MOVE--->true 07-01 05:45:44.140: I/System.out(1620): MyButton--->dispatchTouchEvent--->ACTION_MOVE--->true 07-01 05:45:44.140: I/System.out(1620): MyRelativeLayout--->dispatchTouchEvent--->ACTION_MOVE--->true 07-01 05:45:44.140: I/System.out(1620): MainActivity--->dispatchTouchEvent--->ACTION_MOVE--->true 07-01 05:45:44.140: I/System.out(1620): MainActivity--->dispatchTouchEvent--->ACTION_UP 07-01 05:45:44.140: I/System.out(1620): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP 07-01 05:45:44.140: I/System.out(1620): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP 07-01 05:45:44.150: I/System.out(1620): MyRelativeLayout--->onInterceptTouchEvent--->ACTION_UP--->false 07-01 05:45:44.150: I/System.out(1620): MyButton--->dispatchTouchEvent--->ACTION_UP 07-01 05:45:44.150: I/System.out(1620): MyButton--->onTouch--->UP 07-01 05:45:44.150: I/System.out(1620): MyButton--->onTouchEvent--->ACTION_UP 07-01 05:45:44.150: I/System.out(1620): MyButton--->onTouchEvent--->ACTION_UP--->true 07-01 05:45:44.150: I/System.out(1620): MyButton--->dispatchTouchEvent--->ACTION_UP--->true 07-01 05:45:44.150: I/System.out(1620): MyRelativeLayout--->dispatchTouchEvent--->ACTION_UP--->true 07-01 05:45:44.150: I/System.out(1620): MainActivity--->dispatchTouchEvent--->ACTION_UP--->true可以看到不管是DOWN、MOVE、UP情况下,都会执行MyButton的onTouchEvent方法,但是你却看不到onLongClick以及onClick的身影,原因在于当你移出MyButton的范围之后,MOVE事件会从MessageQueue中移出关于MyButton的click以及longclick监听的Message,这样就不会执行onLongClick以及onClick方法了,这是快速移出MyButton范围的情况输出;如果你在MyButton上面停留一会在移出MyButton范围的话,你会看到onLongClick的输出,但是看不到onClick的输出;总结一下,不管怎样,只要你移出了MyButton范围,onClick是肯定不会执行了,至于onLongClick就要看你的移出速度了;
这样,我对View的事件分发过程做了下简单的测试,自认为比较全了,有什么不正确的地方希望高手赐教,赠人玫瑰,手留余香!!!!!
标签:
原文地址:http://blog.csdn.net/hzw19920329/article/details/51800751