前几天解决了SwipeListview拦截ViewPager滑动事件,今天在ViewPager下面增加一些常规布局,发现在新增布局中设置完点击事件后,在这些新增布局范围内,ListView不能上下滑动,查看SwipeListview中onInterceptTouchEvent()方法,发现不能简单将滑动事件分配给子View,应当对移动事件重写,在判定为上下滑动时,将事件拦截在此,最后改进的结果如下:

downPosition = pointToPosition((int) x, (int) y);

if(downPosition == 1) {

switch (action) {

case MotionEvent.ACTION_MOVE:

checkInMoving(x, y);

if(touchState == TOUCH_STATE_SCROLLING_Y) {

return true;

}

break;

case MotionEvent.ACTION_DOWN:

super.onInterceptTouchEvent(ev);

touchListener.onTouch(this, ev);

touchState = TOUCH_STATE_REST;

lastMotionX = x;

lastMotionY = y;

return false;

default:

break;

}

downPosition = ListView.INVALID_POSITION;

return false;

}