title: How can i load data on specific tab in android?
body: <p>My task is to load data on 50th screen out of 100 screens in one tab activity and also to increment date on forward swipe and decrement date on backward swipe. </p>
  
  <p>I wrote code to increment date and made 50th screen as my current screen but i don't know how to load that current date in 50th screen and to decrement date on backward swipe.</p>
  
  <p>Here is my main activity:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      public static Tab2 self;
      private SectionsPagerAdapter mSectionsPagerAdapter;
      private ViewPager mViewPager;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
  
          // Set up the ViewPager with the sections adapter.
          mViewPager = (ViewPager) findViewById(R.id.container);
          mViewPager.setAdapter(mSectionsPagerAdapter);
          mViewPager.setCurrentItem(50);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
  
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      /**
       * A placeholder fragment containing a simple view.
       */
      public static class PlaceholderFragment extends Fragment {
  
          /**
           * The fragment argument representing the section number for this
           * fragment.
           */
          private static final String ARG_SECTION_NUMBER = "section_number";
  
          public PlaceholderFragment() {
          }
  
          /**
           * Returns a new instance of this fragment for the given section
           * number.
           */
          public static PlaceholderFragment newInstance(int sectionNumber) {
              PlaceholderFragment fragment = new PlaceholderFragment();
              Bundle args = new Bundle();
              args.putInt(ARG_SECTION_NUMBER, sectionNumber);
              fragment.setArguments(args);
              return fragment;
          }
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              View rootView = inflater.inflate(R.layout.fragment_main, container, false);
              TextView textView = (TextView) rootView.findViewById(R.id.section_label);
              textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
              return rootView;
          }
      }
  
      /**
       * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
       * one of the sections/tabs/pages.
       */
      public class SectionsPagerAdapter extends FragmentPagerAdapter {
  
          public SectionsPagerAdapter(FragmentManager fm) {
              super(fm);
          }
  
          @Override
          public int getCount() {
              return 100;
          }
  
  
          @Override
          public Fragment getItem(int position) {
              //TabHost tabHost = Tab2.self.getTabHost();
              //tabHost.setCurrentTab(0);
  
              return Tab2.newInstance(position);
          }
  
          @Override
          public CharSequence getPageTitle(int position) {
               return "SECTION 3";
          }
      }
  }
  </code></pre>
  
  <p>and my tab activity is</p>
  
  <pre><code>public class Tab2 extends Fragment {
      private int position;
  
      public Tab2() {
  
      }
  
      public static Tab2 newInstance(int position) {
          Tab2 fragment = new Tab2();
          Bundle args = new Bundle();
          args.putInt("position", position);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          if (getArguments() != null) {
              position = getArguments().getInt("position");
          }
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
          return inflater.inflate(R.layout.tab2, container, false);
      }
  
      @Override
      public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
          Calendar c = Calendar.getInstance();
          c.add(Calendar.DAY_OF_MONTH, position);
          String dte = sdf.format(c.getTime()).toString();
  
          TextView textView2 =  getView().findViewById(R.id.textView2);
          textView2.setText(dte);
      }   
  }
  </code></pre>