title: How to know which fragment is currently selected in a ViewPager?
body: <p>I use ViewPager loaded with fragments in it and I want to know <strong>which fragment is currently shown or selected</strong> in the viewpager.</p>
  
  <p>The <strong>onResume()</strong> method of each fragments does some logic and so i get problems when the adjacent fragments(left and right) to the currently selected page are also instantiated.</p>
  
  <p><strong>Updated:</strong></p>
  
  <p>Does the fragment get any <strong>callbacks</strong> when it get actually selected?</p>
  
  <p><strong>ViewPager Adapter code:</strong></p>
  
  <pre><code>public class LeftPanelPagerAdapter extends FragmentStatePagerAdapter
   {
  private List&lt;Fragment&gt; fragments;
  
  public LeftPanelPagerAdapter(FragmentManager fm,List&lt;Fragment&gt; fragments) 
  {
      super(fm);
      this.fragments = fragments;
  
  }
  
  @Override
  public Fragment getItem(int position) 
  {
      return this.fragments.get(position);
  }
  
  @Override
  public int getCount() 
  {
  
      return this.fragments.size();
  }
  
  @Override
  public int getItemPosition(Object object) 
  {
      return POSITION_NONE;
  }
  @Override
  </code></pre>