All you need is nested RecyclerView
, one parent one and another inside it and you need this CallBack
to handle swipe events
private final ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
//HERE YOU WILL PERFORM YOUR ACTION FOR SWIPE EVENT i.e CHANGE THE ITEM NO IN RECYCLERVIEW WITH SOMETHING LIKE
// mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1);
}
};
private final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
}
and then you will need to attach it to both RecyclerViews
like this
itemTouchHelper.attachToRecyclerView(mRecyclerView1);
itemTouchHelper.attachToRecyclerView(mRecyclerView2);
This is how you can handle swipe events for both RecyclerViews
at same time
and this is how you can add and remove pages from ViewPager
public void MoveNext(View view) {
//it doesn't matter if you're already in the last item
pager.setCurrentItem(pager.getCurrentItem() + 1);
}
public void MovePrevious(View view) {
//it doesn't matter if you're already in the first item
pager.setCurrentItem(pager.getCurrentItem() - 1);
}
Hope this helps