code: private void setupTabs() {
  		// Setup view pager
  		ViewPager viewpager = (ViewPager) findViewById(R.id.viewpager);
  		viewpager.setAdapter(new MainPagerAdapter(this, getSupportFragmentManager()));
  		viewpager.setOffscreenPageLimit(MainPagerAdapter.NUM_ITEMS);
  		updatePage(viewpager.getCurrentItem());
  
  		// Setup tab layout
  		TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
  		tabLayout.setupWithViewPager(viewpager);
  		viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  			@Override
  			public void onPageScrolled(int i, float v, int i1) {
  			}
  
  			@Override
  			public void onPageSelected(int i) {
  				updatePage(i);
  			}
  
  			@Override
  			public void onPageScrollStateChanged(int i) {
  			}
  		});
  	}
docs: Sets up the tabs.