标签:listview android 冲突 viewpager
很简单 重写ListView
其他类似问题解决ScrollView嵌套ViewPager出现的滑动冲突问题
http://blog.csdn.net/zhangyiacm/article/details/37903071
package com.zy.myview; import android.content.Context; import android.util.AttributeSet; import android.view.GestureDetector; import android.view.GestureDetector.SimpleOnGestureListener; import android.view.MotionEvent; import android.view.View; import android.widget.ListView; /** * 重写ListView解决ListView内部ViewPaper滑动事件冲突问题 * @date 2014-7-17 上午10:53:25 * @author ZhangYi * */ public class MyListView extends ListView { private GestureDetector mGestureDetector; View.OnTouchListener mGestureListener; public MyListView(Context context) { super(context); } public MyListView(Context context, AttributeSet attrs) { super(context, attrs); mGestureDetector = new GestureDetector(new YScrollDetector()); setFadingEdgeLength(0); } public MyListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev); } class YScrollDetector extends SimpleOnGestureListener { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (distanceY != 0 && distanceX != 0) { } if (Math.abs(distanceY) >= Math.abs(distanceX)) { return true; } return false; } } }
<com.zy.myview.MyListView android:id="@+id/zhuye_news_lisview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="@drawable/list_kongbai_fenge" android:listSelector="@drawable/but_select" android:scrollbars="none" android:scrollingCache="false" />
重写ListView解决ListView内部ViewPaper滑动事件冲突问题,布布扣,bubuko.com
重写ListView解决ListView内部ViewPaper滑动事件冲突问题
标签:listview android 冲突 viewpager
原文地址:http://blog.csdn.net/zhangyiacm/article/details/37903267