0

original Viewpager2 can scroll left&right to change page. And I want to add "down to up scroll" to use 'startActivity'

I tried like this...but

Viewpager2 viewpager;
viewpager.getChildAt(0).setonTouchListener(new View.onTouchListener() {
     @Override
     public boolean onTouch(View v, MotionEvent event) {
           gestureDetector.onTouchEvent(event);
           return true;
     }
});

It cannot work original viewpager's left&right scroll. I want to save original's, and add just another scroll. How can i do?

#I searched about onInterceptTouchEvent, DispatchTouchEvent... I cannot find how to use.

Llinh
  • 1
  • 1

1 Answers1

0

you want vertical scroll to start new activity or to scroll through list items? if you want to scroll through list then use recyclerView,see this - Simple Android RecyclerView example

and for starting new activity or any process on swiping(top to bottom or left to right) see this - Android: How to handle right to left swipe gestures

Raj
  • 63
  • 1
  • 9