title: Android: FragmentPagerAdapter: getItem method called twice on First time
body: <p>In My application, I have used the ViewPager.
  Like,</p>
  
  <pre><code>(say main.xml)
  
  &lt;android.support.v4.view.ViewPager
       android:id="@+id/viewPager"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:layout_above="@+id/register_header" /&gt;
  </code></pre>
  
  <p>And Create ViewPager object and ViewPagerAdapter(which extends FragmentPagerAdapter) object in FragmentActivity.</p>
  
  <pre><code>_mViewPager = (ViewPager) findViewById(R.id.viewPager);
  
  _adapter = new ViewPagerAdapter(getApplicationContext(),
           getSupportFragmentManager());
  
  _mViewPager.setAdapter(_adapter);
  </code></pre>
  
  <p>And the Adapter class is like,</p>
  
  <pre><code>public class ViewPagerAdapter extends FragmentPagerAdapter {
      private Context _context;
      private FragmentManager manager;
      private Fragment f;
      private String classname="ViewPagerAdapter";
      public ViewPagerAdapter(Context context, FragmentManager fm) {
          super(fm);  
          _context=context;
          manager=fm;
          }
      @Override
      public Fragment getItem(int position) {
          Log.i(classname,"getItem called"+position);
          f = new Fragment();
          f=MyFragment.newInstance();
          Bundle args = new Bundle();
          args.putInt("position", position);
          f.setArguments(args);
          return f;
      }
  
      @Override
      public int getCount() {
          return User.getPageCount();
      }
  
      @Override
      public int getItemPosition(Object object) {
          return POSITION_NONE;
      }
  }
  </code></pre>
  
  <p>And in MyFragment Class,</p>
  
  <p>In onResume , I have to store the wigets object to the common static variable.</p>
  
  <pre><code>public void onResume() {
          super.onResume();
          pageIndex = getArguments().getInt("position");      
          User.useTextview1=textview1;
          User.useTextview2= textview2;
          User.current_pageIndex=pageIndex;
  
  
  
      }
  </code></pre>
  
  <p>I have to update the textviews got from the User class in the FragmentActivity.
  <strong>My Problem is getItem() method is called twice on First time</strong> 
  In Fact , the view displayed in the emulator is 0th index, but got  1st Index  value in the FragmentActivity.
  If I stopped the calling of getItem() method on second time, I can able to get the 0th index TextView reference in the FragmentActivity.</p>
  
  <p>Please provide me the best way to do this.</p>
  
  <p>Thanks</p>