[android]代码库
//是因为ListView和ViewPager滑动事件冲突,重写一个ListView就可以了
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;
}
}
}
初级程序员
by: 黎明 发表于:2014-03-12 21:45:50 顶(0) | 踩(0) 回复
不错真的很有用
回复评论