单击其子项时禁用滑动视图寻呼机

时间:2015-10-01 13:08:59

标签: android android-viewpager swipe horizontallistview

我正面临着Viewpager的问题。如何在刷子视图时停止滑动查看寻呼机内部适配器。我附加了有关我的屏幕的图像。enter image description here

当我点击Horizo​​ntal ListView时整个Viewpager正在滑动。我希望只有在未触及Horizo​​ntal Listview时才能滑动视图寻呼机。谢谢

1 个答案:

答案 0 :(得分:0)

//here this code is writing for disable scroll of parent item so same thing you 
can do it you can disable it from your child here

vp.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });
vp.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub
            vp.getParent().requestDisallowInterceptTouchEvent(true);
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
            // TODO Auto-generated method stub

        }
    });