标签:android setonitemclicklisten setontouchlistener 冲突
@Override public boolean onTouch(View v, MotionEvent event) { createVelocityTracker(event); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: xDown = event.getRawX(); break; case MotionEvent.ACTION_MOVE: xMove = event.getRawX(); //活动的距离 int distanceX = (int) (xMove - xDown); //获取顺时速度 int xSpeed = getScrollVelocity(); //当滑动的距离大于我们设定的最小距离且滑动的瞬间速度大于我们设定的速度时,返回到上一个activity if(distanceX > XDISTANCE_MIN && xSpeed > XSPEED_MIN) { finish(); //设置切换动画,从右边进入,左边退出 // overridePendingTransition(R.anim.in_from_left, R.anim.out_to_right); }else { return false; } break; case MotionEvent.ACTION_UP: recycleVelocityTracker(); break; default: break; } return false;//返回false即可响应click事件 }
<span style="font-size:24px;"><strong>在最后,返回false即可响应click事件,完美解决处理事件冲突问题!!!!!</strong></span>
Android:完美解决listview的setonitemclicklistener 和 setontouchlistener冲突问题
标签:android setonitemclicklisten setontouchlistener 冲突
原文地址:http://blog.csdn.net/sange77/article/details/40864631