j2emanue
j2emanue

Reputation: 62519

RecyclerView embeded inside a Viewpager - how to enable swiping of viewpager only?

My recyclerview items do not need to be swiped. there only for displaying information and clicking to go to a details page but no swipping. So i'd like to disable swipping on the recyclerview so that the viewpager it is inside of can take the swipe and move to another tab. The page is pretty simple its just a fragment of recyclerview items inside of a viewPager.

What i have tried so far is using the folling simplecallback:

 ItemTouchHelper.SimpleCallback simpleCallbackItemTouchHelper = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.RIGHT){

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {

        }


@Override
public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
   return 0; //i thought this would disable it but it didn't

}};

How can this be achieved ?

Upvotes: 0

Views: 241

Answers (1)

Jagruttam Panchal
Jagruttam Panchal

Reputation: 3200

You may apply RecyclerView's TouchListener to null.

Upvotes: 1

Related Questions