title: Android - How to swipe the tab in TabLayout using Recyclerview
body: <p>I have the four Tabs in a fragment. I am loading data into RecyclerView.. I am not using each fragment for each tab and am using single fragment for all Tabs. I just changed data set only in the Adapter. While selecting tab its loading that data so its working good and well. Now I want to swipe the page it should go to next tab...</p>
  
  <pre><code>public class CreateFlipFragment extends Fragment {
  
  private TabLayout tabLayout;
  private RecyclerView recyclerView;
  private StickerListAdapter adapter;
  private ArrayList&lt;Sticker&gt; stickerList;
  private ViewPager viewPagerStickers;
  
  public CreateFlipFragment() {
      // Required empty public constructor
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      view = inflater.inflate(R.layout.fragment_create_flip_new, container, false);
  
      tabLayout = (TabLayout) view.findViewById(R.id.tablayout_flips);
      recyclerView = (RecyclerView) view.findViewById(R.id.rv_flips_sticker);
      viewPagerStickers = (ViewPager) view.findViewById(R.id.vp_stickers);
  
      stickerList = new ArrayList&lt;&gt;();
      adapter = new StickerListAdapter(stickerList);
      recyclerView.setHasFixedSize(true);
      GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 3);
      recyclerView.setLayoutManager(layoutManager);
      recyclerView.setAdapter(adapter);
  
      setupTab();
  
      tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
  
          viewPagerStickers.setCurrentItem(tab.getPosition());
  
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
  
              switch (tab.getPosition()) {
                  case 0:
                      loadStickers1();
                      break;
                  case 1:
                      loadStickers2();
  
                      }
                      break;
                  case 2:
                      loadStickers4();
  
                      break;
                  case 3:
                      loadStickers5();
  
                      break;
                  default:
                      stickerList.clear();
                      adapter.notifyDataSetChanged();
                      break;
              }
          }
  
          @Override
          public void onTabUnselected(TabLayout.Tab tab) {
  
          }
  
          @Override
          public void onTabReselected(TabLayout.Tab tab) {
  
          }
      });
     }
  
     private void setupTab() {
      tabLayout.addTab(tabLayout.newTab());
      tabLayout.addTab(tabLayout.newTab());
      tabLayout.addTab(tabLayout.newTab());
      tabLayout.addTab(tabLayout.newTab());
      tabLayout.getTabAt(0).setIcon(R.drawable.meme0);
      tabLayout.getTabAt(1).setIcon(R.drawable.bubble0);
      tabLayout.getTabAt(2).setIcon(R.drawable.ic_sticker_text_off);
      tabLayout.getTabAt(3).setIcon(R.drawable.ic_sticker_image_off);
     }
  
     private void loadStickers1() {
      stickerList.clear();
      stickerList.add(new Sticker(null, R.drawable.word4, Sticker.STICKER_TYPE.STICKER));
      stickerList.add(new Sticker(null, R.drawable.word5, Sticker.STICKER_TYPE.STICKER));
      stickerList.add(new Sticker(null, R.drawable.word6, Sticker.STICKER_TYPE.STICKER));
      adapter.notifyDataSetChanged();
     }
     private void loadStickers2() {
      stickerList.clear();
      stickerList.add(new Sticker(null, R.drawable.word4, Sticker.STICKER_TYPE.STICKER));
      stickerList.add(new Sticker(null, R.drawable.word5, Sticker.STICKER_TYPE.STICKER));
      stickerList.add(new Sticker(null, R.drawable.word6, Sticker.STICKER_TYPE.STICKER));
      adapter.notifyDataSetChanged();
     }
     private void loadStickers3() {
      stickerList.clear();
      stickerList.add(new Sticker(null, R.drawable.word4, Sticker.STICKER_TYPE.STICKER));
      stickerList.add(new Sticker(null, R.drawable.word5, Sticker.STICKER_TYPE.STICKER));
      stickerList.add(new Sticker(null, R.drawable.word6, Sticker.STICKER_TYPE.STICKER));
      adapter.notifyDataSetChanged();
     }
     private void loadStickers4() {
      stickerList.clear();
      stickerList.add(new Sticker(null, R.drawable.word4, Sticker.STICKER_TYPE.STICKER));
      stickerList.add(new Sticker(null, R.drawable.word5, Sticker.STICKER_TYPE.STICKER));
      stickerList.add(new Sticker(null, R.drawable.word6, Sticker.STICKER_TYPE.STICKER));
      adapter.notifyDataSetChanged();
     }
    }
  </code></pre>
  
  <p>fragment_create_flip_new.xml</p>
  
  <pre><code>&lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
  
      &lt;android.support.design.widget.TabLayout
          android:id="@+id/tablayout_flips"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/gray_very_light"
          app:tabGravity="fill"
          app:tabIndicatorHeight="1dp"
          app:tabMode="fixed"
          app:tabSelectedTextColor="@color/colorPrimary"
          app:tabTextAppearance="@style/TabDefalt"
          app:tabTextColor="@color/text_color" /&gt;
  
       &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/rv_flips_sticker"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@color/transparent" /&gt;
  
       &lt;android.support.v4.view.ViewPager
          android:id="@+id/vp_stickers"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Everything working fine... now i want add swipe the page it goes to next tab and change that data set... Help me... Thanks in advance...</p>