title: Tabs get dynamically added,how to settext to it
body: <pre><code>package com.agri.kishan;
  
  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 android.widget.TextView;
  import android.widget.Toast;
  import com.agri.kishan.OneFragment;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import com.agri.kishan.OneFragment;
  
  public class ScrollableTabsActivity extends AppCompatActivity {
  
      private Toolbar toolbar;
      private TabLayout tabLayout;
      private ViewPager viewPager;
      public static int tabsele;
      public static String realqus="this is a sample qus";
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_scrollable_tabs);
          //
  
          //
          toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          viewPager = (ViewPager) findViewById(R.id.viewpager);
          setupViewPager(viewPager);
  
          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());
                  Toast.makeText(getApplicationContext(),tab.getPosition()+"",Toast.LENGTH_SHORT).show();
                   tabsele=tab.getPosition();
                  /////////////////////////////////////////
                  /////////////////////////////////
                  ///////////////////
  </code></pre>
  
  <p><strong>I want to set text according to the position,I get position successfully</strong> </p>
  
  <pre><code>                if(tabsele==0)
                  {
                     OneFragment.tv.setText("hai");
  
  
  
                  } else if(tabsele==1)
                  {
                      OneFragment.tv.setText("bye");
                  }
                  //////////////////
                  ////////////////////////////////
                  ///////////////////////////////////////////
  
  
  
              }
  
              @Override
              public void onTabUnselected(TabLayout.Tab tab) {
  
              }
  
              @Override
              public void onTabReselected(TabLayout.Tab tab) {
  
              }
          });
  
      }
  
      private void setupViewPager(ViewPager viewPager) {
          ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
          for(int i=0;i&lt;=Card_display.counttabs;i++) {
              adapter.addFrag(new OneFragment(), "Qus:"+i);
          }
  
          viewPager.setAdapter(adapter);
      }
  
      class ViewPagerAdapter extends FragmentPagerAdapter {
          private final List&lt;Fragment&gt; mFragmentList = new ArrayList&lt;&gt;();
          private final List&lt;String&gt; mFragmentTitleList = new ArrayList&lt;&gt;();
  
  
          public ViewPagerAdapter(FragmentManager manager) {
              super(manager);
          }
  
          @Override
          public Fragment getItem(int position) {
  
              return mFragmentList.get(position);
          }
  
  
          @Override
          public int getCount() {
              return mFragmentList.size();
          }
  
          public void addFrag(Fragment fragment, String title) {
              mFragmentList.add(fragment);
              mFragmentTitleList.add(title);
  
          }
  
          @Override
          public CharSequence getPageTitle(int position) {
              return mFragmentTitleList.get(position);
          }
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p>Fragment page
    the fragment page is a simple fragment page which has an text view in it,
    i get the postion of the tab from activity
    i want to change the text to the textview in the fragment according to the position from the activity</p>
  </blockquote>
  
  <p><strong>Fragement page</strong>
      package com.agri.kishan;</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentActivity;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  
  import com.agri.kishan.ScrollableTabsActivity;
  
  
  public class OneFragment extends Fragment {
      /////////////////////////
      ////////////////////////////
      //////////////////
     public static TextView  tv;
      ////////////////////////
      ////////////////////////
      /////////////////////
  
      public OneFragment() {
          // Required empty public constructor
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
  
  
          super.onCreate(savedInstanceState);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View view =  inflater.inflate(R.layout.fragment_one,
                  container, false);
  
  
          tv=(TextView)view.findViewById(R.id.realqus);
  
  
  
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.fragment_one, container, false);
      }
  
  
  }
  </code></pre>