title: Unable to get subtab upon clicking tab by using new android support Material design TabLayout
body: <p>My requirement is to put Main Tabs on the screen with default selected subtabs and its associated display. On clicking of 
  any main tab, it should replace existing subtab &amp; its associated display. I am currently working in Material desin Tablayout.</p>
  
  <p>Here is my code for displaying main tabs</p>
  
  <pre><code>    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
      tabLayout.setupWithViewPager(viewPager);
  
      TabLayout maintabLayout = (TabLayout) findViewById(R.id.maintabs);
      maintabLayout.addTab(maintabLayout.newTab().setText("Product"));
      maintabLayout.addTab(maintabLayout.newTab().setText("Store"));
      maintabLayout.addTab(maintabLayout.newTab().setText("Company"));
      maintabLayout.addTab(maintabLayout.newTab().setText("Service"));
      maintabLayout.addTab(maintabLayout.newTab().setText("User"));
  </code></pre>
  
  <p>which works well</p>
  
  <p>The code for replacing subtab &amp; its associated display is as follows (this is not working and hence need suggestion)</p>
  
  <pre><code>          maintabLayout.setOnTabSelectedListener(new       
          TabLayout.ViewPagerOnTabSelectedListener(viewPager) {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
              int numTab = tab.getPosition();
              switch (numTab) {
                  case 0://Product
                      ViewPager pviewPager = (ViewPager)            
  
                      findViewById(R.id.viewpager);
                      String[] pname = {"ProCat1","ProCat2","ProCat3"};
                      pviewPager.setAdapter(new  
                      FragmentPageAdapter(getSupportFragmentManager(),
                              MainActivity.this));
                      return;
                  case 1://Store
          ViewPager sviewPager = (ViewPager) findViewById(R.id.viewpager);
                      String[] pname = {"Store1","Store2","Store3"};
                      sviewPager.setAdapter(new 
                    FragmentPageAdapter(getSupportFragmentManager(),
                              MainActivity.this));
  
                      return;
                  case 2://Company
          ViewPager cviewPager = (ViewPager) findViewById(R.id.viewpager);
                      String[] pname = {"Comp1","Comp2","Comp3"};
                      cviewPager.setAdapter(new 
                 FragmentPageAdapter(getSupportFragmentManager(),
                              MainActivity.this));
  
                      return;
                  case 3://Service
          ViewPager serviewPager = (ViewPager) findViewById(R.id.viewpager);
                      String[] pname = {"Serv1","Serv2","Serv3"};
                      serviewPager.setAdapter(new 
                   FragmentPageAdapter(getSupportFragmentManager(),
                              MainActivity.this));
  
                      return;
                  case 4://User
                      ViewPager uviewPager = (ViewPager)   
                 findViewById(R.id.viewpager);
                      String[] uname = {"Sample1", "Sample2", "Sample3"};
             uviewPager.setAdapter(new 
            FragmentPageAdapter(getSupportFragmentManager(),
                              MainActivity.this));
                      return;
              }
          }
  
          @Override
          public void onTabUnselected(TabLayout.Tab tab) {
  
          }
  
          @Override
          public void onTabReselected(TabLayout.Tab tab) {
  
          }
      });
  </code></pre>