code: @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          final InfiniteViewPager viewPager = (InfiniteViewPager) findViewById(R.id.infinite_viewpager);
          viewPager.setAdapter(new MyInfinitePagerAdapter(0));
          viewPager.setPageMargin(20);
          viewPager.setOnInfinitePageChangeListener(new InfiniteViewPager.OnInfinitePageChangeListener() {
              @Override
              public void onPageScrolled(final Object indicator, final float positionOffset,
                                         final int positionOffsetPixels) {
                  Log.d("InfiniteViewPager", "onPageScrolled ".concat(String.valueOf(indicator)));
              }
  
              @Override
              public void onPageSelected(final Object indicator) {
                  Log.d("InfiniteViewPager", "onPageSelected " + indicator.toString());
              }
  
              @Override
              public void onPageScrollStateChanged(final int state) {
                  Log.d("InfiniteViewPager", "state " + String.valueOf(state));
              }
          });
  
          final Button btn = (Button) findViewById(R.id.current_item_btn);
          btn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(final View v) {
                  viewPager.setCurrentIndicator(6);
              }
          });
      }
docs: Called when the activity is first created.