PullToRefreshScrollView嵌套SwipeMenuListView冲突问题解决
参考:
http://blog.csdn.net/u012255016/article/details/46048797
public class NoScrollSwipeMenuListView extends SwipeMenuListView { private GestureDetector mGestureDetector; View.OnTouchListener mGestureListener; public NoScrollSwipeMenuListView(Context context) { super(context); mGestureDetector = new GestureDetector(context, onGestureListener); } public NoScrollSwipeMenuListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mGestureDetector = new GestureDetector(context, onGestureListener); } public NoScrollSwipeMenuListView(Context context, AttributeSet attrs) { super(context, attrs); mGestureDetector = new GestureDetector(context, onGestureListener); } private GestureDetector.OnGestureListener onGestureListener = new GestureDetector.SimpleOnGestureListener() { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (Math.abs(distanceY) >= Math.abs(distanceX)) { return true; } // 当手指触到listview的时候,让父ScrollView交出ontouch权限,也就是让父scrollview 停住不能滚动 setParentScrollAble(false); return false; } }; /** * 是否把滚动事件交给父scrollview * * @param flag */ private void setParentScrollAble(boolean flag) { // 这里的parentScrollView就是listview外面的那个scrollview getParent().requestDisallowInterceptTouchEvent(!flag); } @Override public boolean onTouchEvent(MotionEvent ev) { mGestureDetector.onTouchEvent(ev); return super.onTouchEvent(ev); } /* * * 重写该方法,达到使ListView适应ScrollView的效果 */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } }