content: package com.study.benchmarkorm;
  
  import android.os.Bundle;
  import android.support.design.widget.TabLayout;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  
  import butterknife.Bind;
  import butterknife.ButterKnife;
  
  public class MainActivity extends AppCompatActivity {
  
      @Bind(R.id.container)
      ViewPager mViewPager;
  
      @Bind(R.id.tab_layout)
      TabLayout mTabLayout;
  
      @Bind(R.id.toolbar)
      Toolbar toolbar;
  
      SectionsPagerAdapter mSectionsPagerAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          ButterKnife.bind(this);
          setSupportActionBar(toolbar);
          mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
          mViewPager.setAdapter(mSectionsPagerAdapter);
          mTabLayout.addTab(mTabLayout.newTab().setText("Simple"),0);
          mTabLayout.addTab(mTabLayout.newTab().setText("Complex"),1);
          mTabLayout.addTab(mTabLayout.newTab().setText("Balanced"),2);
          mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
          mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
          mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
              @Override
              public void onTabSelected(TabLayout.Tab tab) {
                  mViewPager.setCurrentItem(tab.getPosition());
              }
  
              @Override
              public void onTabUnselected(TabLayout.Tab tab) {
  
              }
  
              @Override
              public void onTabReselected(TabLayout.Tab tab) {
  
              }
          });
      }
  
      public class SectionsPagerAdapter extends FragmentPagerAdapter{
  
          public SectionsPagerAdapter(FragmentManager fm) {
              super(fm);
          }
  
          @Override
          public Fragment getItem(int position) {
              return BasicFragment.newInstance(position);
          }
  
          @Override
          public int getCount() {
              return 3;
          }
      }
  }
  