So to start with I pinched the code from here, I have set the page titles to display the date, which works well, but I am having trouble with the positions and what Date is actually being sent over in the Bundle, it starts off with it being todays date and the position being 2000,
I swipe right and the position and date go to 2002 and 2 days after today, but the PagerTitleStrip will be correct and say its tomorrow.
The same happens if I swipe left, apart from its decremented.
So my question is, "Do you know why this strange behaviour is happening and how can I fix it?"
So here is the code, am I doing something wrong?
Also, when the app loads up to the ViewPager screen, the PagerTitleStrip will be as follows (I think this is what is causing the issue)
[yesterdays date] [todays date] [tomorrows date]
public class MainMenuActivity extends AppCompatActivity {
/**
 * The {@link android.support.v4.view.PagerAdapter} that will provide
 * fragments for each of the sections. We use a
 * {@link FragmentPagerAdapter} derivative, which will keep every
 * loaded fragment in memory. If this becomes too memory intensive, it
 * may be best to switch to a
 * {@link android.support.v4.app.FragmentStatePagerAdapter}.
 */
BootstrapPagerAdapter mSectionsPagerAdapter;
/**
 * The {@link ViewPager} that will host the section contents.
 */
ViewPager mViewPager;
ArrayList<Set> selected = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_menu_setup);
    try {
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setLogo(R.mipmap.ic_launcher);
        getSupportActionBar().setDisplayUseLogoEnabled(true);
        getSupportActionBar().setTitle("ProjectME");
    } catch(NullPointerException n) {
        Log.v("nullPointerCaught", n.toString());
    }
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new BootstrapPagerAdapter(getResources(), getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setCurrentItem(2000);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    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;
    }
    if(id == R.id.action_add) {
        Intent intent = new Intent(MainMenuActivity.this, CategoryListView.class);
        startActivity(intent);
    }
    if(id == R.id.action_cal) {
        Intent intent = new Intent(MainMenuActivity.this, CalendarView.class);
        startActivity(intent);
    }
    if(id == R.id.action_copy) {
        Toast.makeText(getApplicationContext(), "Copy has been clicked", Toast.LENGTH_SHORT).show();
    }
    return super.onOptionsItemSelected(item);
}
public ArrayList<Set> getSelected() {
    return selected;
}
public void setSelected(ArrayList<Set> selected) {
    this.selected = selected;
}
public class BootstrapPagerAdapter extends FragmentPagerAdapter  {
    /**
     * Create pager adapter
     *
     * @param resources
     * @param fragmentManager
     */
    public BootstrapPagerAdapter(Resources resources, FragmentManager fragmentManager) {
        super(fragmentManager);
    }
    @Override
    public int getCount() {
        return 10000;
    }
    @Override
    public int getItemPosition(Object object) {
        return super.getItemPosition(object);
    }
    @Override
    public CharSequence getPageTitle(int position) {
        DateTime pagerdate = DateTime.now(TimeZone.getDefault());
        DateTime days = pagerdate.plusDays(position - 2000);
        return days.format("DD/MM/YYYY").toString();
    }
    @Override
    public Fragment getItem(int position) {
        DateTime pagerdate = DateTime.now(TimeZone.getDefault());
        DateTime days = pagerdate.plusDays(position - 2000);
        Bundle bundle = new Bundle();
        bundle.putString("date", days.format("DD/MM/YYYY").toString());
        bundle.putInt("position", position);
        Log.v("date", days.format("DD/MM/YYYY").toString());
        Log.v("position", position + "");
        MainMenuView2 mainMenuView2 = new MainMenuView2();
        mainMenuView2.setArguments(bundle);
        return mainMenuView2;
    }
}
}
 
     
    