title: Setting the names of each tab of viewpager
body: <p>At the moment I have seven tabs that I are intially just blank, i.e. <code>""</code>. Those values would be changed to the values of a <code>String[]</code> array that I am passing through a method call shown below</p>
  
  <p>So I have method like this in one of my classes:</p>
  
  <pre><code>CustomTabAdapter customTabAdapter = new CustomTabAdapter();
  customTabAdapter.setTabNames(temps);
  </code></pre>
  
  <p>Basically this sets the tab names for the <code>fragmentpager</code> but it does not update the actual tabs. When I do print <code>temps</code> in this class via a <code>for loop</code> it prints all the names in <code>temps</code> - which means that temps exists but it never updates the tabs.</p>
  
  <p>I believe it doesn't update because I am not overriding the original values in my <code>CustomTabAdapter</code> class but here is my <code>CustomTabAdapter</code> class:</p>
  
  <pre><code>public class CustomTabAdapter extends FragmentPagerAdapter {
  
      String names[];
      Context context;
  
      public CustomTabAdapter(FragmentManager fragmentManager, Context context){
          super(fragmentManager);
          this.context = context;
          names = new String[7];
          Arrays.fill(names, "");
      }
  
      @Override
      public Fragment getItem(int position) {
          switch (position){
              case 0:
                  return new TabOne();
              case 1:
                  return new TabTwo();
              case 2:
                  return new TabThree();
              case 3:
                  return new TabFour();
              case 4:
                  return new TabFive();
              case 5:
                  return new TabSix();
              case 6:
                  return new TabSeven();
              default:
                  return null;
          }
      }
  
      public void setTabNames(String[] input){
          names = Arrays.copyOf(input, input.length);
      }
  
      @Override
      public int getCount() {
          return names.length;
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          return names[position];
      }
  }
  </code></pre>
  
  <p>This is my <code>TabsGUI</code> where I display all the tabs:</p>
  
  <pre><code>public class TabsViewGUI extends AppCompatActivity {
      TabLayout tabLayout;
      ViewPager viewPager;
      ActionBar actionBar;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.users_page);
          viewPager = (ViewPager) findViewById(R.id.viewPagerUsers);
          CustomTabAdapter customTabAdapter = new CustomTabAdapter(getSupportFragmentManager(), TabsViewGUI.this);
          viewPager.setAdapter(customTabAdapter);
          viewPager.setOffscreenPageLimit(customTabAdapter.getCount());
          populate();
          tabLayout = (TabLayout) findViewById(R.id.tabs);
          tabLayout.setupWithViewPager(viewPager);
          tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
              @Override
              public void onTabSelected(TabLayout.Tab tab) {
                  viewPager.setCurrentItem(tab.getPosition());
              }
  
              @Override
              public void onTabUnselected(TabLayout.Tab tab) {
                  //viewPager.setCurrentItem(tab.getPosition());
              }
  
              @Override
              public void onTabReselected(TabLayout.Tab tab) {
                  //viewPager.setCurrentItem(tab.getPosition());
              }
          });
      }
  }
  </code></pre>
  
  <p>How do I update the tab names because they don't seem to be updating at the moment</p>
  
  <p>Thanks</p>