title: Android ViewPager with setCurrentItem not working properly
body: <p>Trying to implement circular view pager(Pagination). In the below code snippet, the <code>setCurrentItem</code> method of the <code>Viewpager</code>is set to first position(0th index), but it always moves to the second position(1st index). </p>
  
  <p>Below is the code,
  <strong>ViewPagerListener.java</strong></p>
  
  <pre><code> mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
              @Override
              public void onPageScrolled(int positionOfView, float positionOffset, int positionOffsetPixels) {
                  LogUtil.d(TAG, "START of onPageScrolled");
                  mPosition = positionOfView;
                  LogUtil.d(TAG, "COMPLETION of onPageScrolled");
              }
  
              @Override
              public void onPageSelected(int position) {
                  LogUtil.d(TAG, "START of onPageSelected");
                  //LogUtil.d(TAG, "Position :" + position + ", " + "Count of pager adapter :" + (mViewPager.getAdapter().getCount() - 1));
                  LogUtil.d(TAG, "COMPLETION of onPageSelected");
              }
  
              @Override
              public void onPageScrollStateChanged(int state) {
                  LogUtil.d(TAG, "START of onPageScrollStateChanged");
                  if (state == ViewPager.SCROLL_STATE_DRAGGING &amp;&amp; mPosition == 5) {
                      LogUtil.d(TAG, "trying to move to first");
                      currentItemInViewPager(0); //---&gt; This is the position where I am setting the view to move back to start position(0th index) 
  
                  }
                  LogUtil.d(TAG, "COMPLETION of onPageScrollStateChanged");
  
              }
          });
  
  @Override
      public void currentItemInViewPager(int index) {
          LogUtil.d(TAG, "START of currentItemInViewPager");
          if (index == 0) {
              if (getChildFragmentManager().findFragmentByTag("TAG_INTRO_FRAGMENT") != null) {
                  LogUtil.d(TAG, "Removed");
                  getChildFragmentManager().beginTransaction().remove(getChildFragmentManager().findFragmentByTag("TAG_INTRO_FRAGMENT")).commit();
              }
              mViewPager.setVisibility(View.VISIBLE);
              mTabLayout.setVisibility(View.VISIBLE);
              mPagerAdapter = new TutorialPagerAdapter(getChildFragmentManager(), this);
              mViewPager.setAdapter(mPagerAdapter);
              mTabLayout.setupWithViewPager(mViewPager, true);
          }
          mViewPager.setCurrentItem(index);
          LogUtil.d(TAG, "COMPLETION of currentItemInViewPager");
      }
  </code></pre>
  
  <p>Please let me know if I am missing out anything </p>
  
  <p>Thanks</p>