title: How can I use pager.setCurrentItem() inside a fragment?
body: <p>I created many  fragments, Fragment1 , Fragment2.. , Fragment50 Inside the first  fragment with listener method I want to call Fragment40. But I didnt manage. inside the listener these lines runs</p>
  
  <pre><code>pager.setCurrentItem(0);
  pager.setCurrentItem(pager.getCurrentItem() + 1);
  pager.setCurrentItem(pager.getCurrentItem() - 1);
  But pager.setCurrentItem(40); not run. Gives errors. Any help please?
  //First Fragment01
  //I want to call Fragment40
  public class Frag_2 extends  Fragment implements 
          OnClickListener, AdapterView.OnItemSelectedListener {
  //....................................................
  public void onActivityCreated(Bundle savedInstanceState) {super.onActivityCreated(savedInstanceState);
  final ViewPager pager = (ViewPager) getActivity().findViewById(R.id.pager);
  View txtdersHakkinda1 = (View) getActivity().findViewById(R.id.txtDersHakkinda1);
  txtdersHakkinda1.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
  pager.setCurrentItem(pager.getCurrentItem()+40);    // not run
  //  pager.setCurrentItem(0);    //runs
  //  pager.setCurrentItem(pager.getCurrentItem() + 1);
  //  pager.setCurrentItem(pager.getCurrentItem() - 1);
  }
  } );    
  //......................................................................
  }
  /////////////////////// If many fragments --&gt; FragmentStatePagerAdapter /////////////
  public class MyPagerAdapter extends FragmentStatePagerAdapter {
  private List&lt;Fragment&gt; fragments;
  public MyPagerAdapter(FragmentManager fm) {
  super(fm);
  this.fragments = new ArrayList&lt;Fragment&gt;();
  fragments.add(new Frag_1&lt;Object&gt;());
  fragments.add(new Frag_2());
  fragments.add(new Frag_3());
  fragments.add(new Frag_4());
   .....................
  fragments.add(new Frag_50());
  }
  @Override
  public Fragment getItem(int position) {
  return fragments.get(position);
  }
  @Override
  public int getCount() {
  return fragments.size();
  }
  }
  </code></pre>