title: Passing position as an argument to Fragment In FragmentPagerAdapter
body: <p>The getItem() position is not always right! Sometimes it will show 0,1,2,3,4 then if I go back it shows a different position (4,2,3,1,0). What is the proper way to use "position", if I need the position to pass into an arraylist/treemap???</p>
  
  <pre><code>02-18 20:07:22.453  11479-11479/com.app E/aaa﹕ position created:0
  02-18 20:07:22.453  11479-11479/com.app E/aaa﹕ position created:1
  02-18 20:07:29.053  11479-11479/com.app E/aaa﹕ position created:2
  02-18 20:07:35.503  11479-11479/com.app E/aaa﹕ position created:0
  </code></pre>
  
  <p>The line:</p>
  
  <pre><code> return SingleCard.newInstance(get_all_cards_as_objects().get(position));
  </code></pre>
  
  <p>Needs the correct position, not the one being rendered into memory! I need the data inside the fragment to change with the actual page position. It will know the data to grab (from the map) based off the actual page position.  </p>
  
  <pre><code>final ViewPager pager = (ViewPager) findViewById(R.id.pager);
          this.parent_nested_fragment_activity = this;
  
          pager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()){
              private final int PARENT_COUNT = get_all_cards_as_objects().size();
  
              @Override
              public Object instantiateItem(ViewGroup container, final int position) {
                  Object obj = super.instantiateItem(container, position);
                  pager.setObjectForPosition(obj, position);
                  return obj;
              }
  
              @Override
              public Fragment getItem(int position) {
              Toast.makeText(CardDealer.this,"Selected page position: " + position, Toast.LENGTH_SHORT).show();
              Log.e("aaa", "position created:" + position);
                      return SingleCard.newInstance(get_all_cards_as_objects().get(position));
              }
  </code></pre>
  
  <p>I have a problem like his, but that answer did not help: 
  <a href="https://stackoverflow.com/questions/17391460/fragmentpageradapter-getitem-wrong-position">FragmentPagerAdapter getItem wrong position</a></p>
  
  <p>I'm also not sure how to implement this answer into my fragments: <a href="https://stackoverflow.com/questions/13214063/getitem-calling-multiple-time-in-fragmentpageradapter">getItem() calling multiple time in FragmentPagerAdapter</a></p>
  
  <p>Like this:
  <a href="https://stackoverflow.com/questions/9384794/weird-dissappearing-fragments-with-fragmentpageradapter?rq=1">Weird dissappearing Fragments with FragmentPagerAdapter</a></p>
  
  <p>Basically I've looked into:</p>
  
  <pre><code>pager.getCurrentItem();
  </code></pre>
  
  <p>How do I pass this into an already created fragment withing getItem();</p>
  
  <pre><code> return SingleCard.newInstance(get_all_cards_as_objects().get(pager.getCurrentItem()));
  </code></pre>