android SwipeMenuListView ScrollView 滑动冲突
2015-12-31 16:28
435 查看
android SwipeMenuListView ScrollView 滑动的时候冲突,引起在删除的时候有问题.
在@Override
public boolean onTouchEvent(MotionEvent ev) {
requestDisallowInterceptTouchEvent(true);
return super.onTouchEvent(ev);
}
requestDisallowInterceptTouchEvent(true);
这是截取滑动的方法.
能改善滑动引起的冲突,但是还是有bug..
google上的..还没试过.
ScrollView的上下事件与ListView的左右事件冲突
参考: http://www.lxway.com/826122882.htm
(二)ScrollView的上下事件与ListView的左右事件冲突
重写ListView
在@Override
public boolean onTouchEvent(MotionEvent ev) {
requestDisallowInterceptTouchEvent(true);
return super.onTouchEvent(ev);
}
requestDisallowInterceptTouchEvent(true);
这是截取滑动的方法.
能改善滑动引起的冲突,但是还是有bug..
google上的..还没试过.
ScrollView的上下事件与ListView的左右事件冲突
参考: http://www.lxway.com/826122882.htm
(二)ScrollView的上下事件与ListView的左右事件冲突
重写ListView
public class MySwipeMenuListView extends SwipeMenuListView { public MySwipeMenuListView(Context context) { super(context); mGestureDetector = new GestureDetector(context,onGestureListener); } public MySwipeMenuListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mGestureDetector = new GestureDetector(context,onGestureListener); } public MySwipeMenuListView(Context context, AttributeSet attrs) { super(context, attrs); mGestureDetector = new GestureDetector(context,onGestureListener); } // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // //setParentScrollAble(false);//当手指触到listview的时候,让父ScrollView交出ontouch权限,也就是让父scrollview 停住不能滚动 // Log.w("MyLog", "onInterceptTouchEvent down"); // case MotionEvent.ACTION_MOVE: // // Log.w("MyLog", "onInterceptTouchEvent move"); // break; // // case MotionEvent.ACTION_UP: // Log.w("MyLog", "onInterceptTouchEvent up"); // // case MotionEvent.ACTION_CANCEL: // // Log.w("MyLog", "onInterceptTouchEvent cancel"); // //setParentScrollAble(true);//当手指松开时,让父ScrollView重新拿到onTouch权限 // // break; // default: // break; // // } // // return super.onInterceptTouchEvent(ev) ; // } @Override public boolean onTouchEvent(MotionEvent ev) { boolean b = mGestureDetector.onTouchEvent(ev); Log.w("MyLog","-- "+ b+" --"); return super.onTouchEvent(ev); } private GestureDetector mGestureDetector; View.OnTouchListener mGestureListener; private GestureDetector.OnGestureListener onGestureListener = new GestureDetector.SimpleOnGestureListener(){ // @Override // public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // Log.w("MyLog","onFling"); // float x = e2.getX() - e1.getX(); // float y = e2.getY() - e1.getY(); // if (Math.abs(y) >= Math.abs(x)){ // setParentScrollAble(false); // return true; // } // //当手指触到listview的时候,让父ScrollView交出ontouch权限,也就是让父scrollview 停住不能滚 4000 动 // setParentScrollAble(true); // return false; // } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.w("MyLog", "onScroll"); if (distanceY != 0 && distanceX != 0) { } 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 Log.w("MyLog", "setParentScrollAble -- " + flag); getParent().requestDisallowInterceptTouchEvent(!flag); } }
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories