视图鳍状肢有4个列表视图.当我使用在视图鳍状肢上实现的手势监听器翻转视图鳍状肢时,它工作正常.但我无法滚动列表视图,因为触摸事件无法从视图鳍状态向下流入列表视图.请提供解决方案.
private class MyVIEwFlipper extends VIEwFlipper implements OnGestureListener { GestureDetector gestureScanner = new GestureDetector(this); Context context; public MyVIEwFlipper(Context context) { super(context); this.context=context; } @OverrIDe public boolean onIntercepttouchEvent(MotionEvent event) { return gestureScanner.ontouchEvent(event); } @OverrIDe public boolean ontouchEvent(MotionEvent event) { return gestureScanner.ontouchEvent(event); } @OverrIDe public boolean onDown(MotionEvent arg0) { return true; } @OverrIDe public boolean onFling(MotionEvent e1, MotionEvent e2, float veLocityX, float veLocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) return false; // right to left swipe if (e1.getX() - e2.getX() > SWIPE_MIN_disTANCE && Math.abs(veLocityX) > SWIPE_THRESHolD_VELociTY) { this.setoutAnimation(AnimationUtils.loadAnimation(context,R.anim.push_left_out)); this.setInAnimation(AnimationUtils.loadAnimation(context,R.anim.push_left_in)); this.showNext(); return true; } else if (e2.getX() - e1.getX() > SWIPE_MIN_disTANCE && Math.abs(veLocityX) > SWIPE_THRESHolD_VELociTY) { this.setoutAnimation(AnimationUtils.loadAnimation(context,R.anim.push_right_out)); this.setInAnimation(AnimationUtils.loadAnimation(context,R.anim.push_right_in)); this.showPrevIoUs(); return true; } else if (e1.getY() - e2.getY() > SWIPE_MIN_disTANCE && Math.abs(veLocityY) > SWIPE_THRESHolD_VELociTY) { return true; } else if (e2.getY() - e1.getY() > SWIPE_MIN_disTANCE && Math.abs(veLocityY) > SWIPE_THRESHolD_VELociTY) { return true; } } catch (Exception e) { e.printstacktrace(); //Toast.makeText(context, "Error Occurred", Toast.LENGTH_LONG); } return false; } @OverrIDe public voID onLongPress(MotionEvent e) { } @OverrIDe public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { //I want this event to be handled by List vIEw this.getCurrentVIEw().findVIEwWithTag("hIErarchy_List").dispatchtouchEvent(e1); Log.i(LOG_TAG, "Scroll"); return false; } @OverrIDe public voID onShowPress(MotionEvent e) { } @OverrIDe public boolean onSingleTapUp(MotionEvent e) { //DO something return false; }}
解决方法:
@OverrIDepublic boolean onIntercepttouchEvent(MotionEvent event) { gestureScanner.ontouchEvent(event); return false;}@OverrIDepublic boolean ontouchEvent(MotionEvent event) { gestureScanner.ontouchEvent(event); return false; }
希望事件将传递下去.
总结以上是内存溢出为你收集整理的Listview没有滚动浏览android中的视图鳍状肢全部内容,希望文章能够帮你解决Listview没有滚动浏览android中的视图鳍状肢所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)