Code example for ViewPager

Methods: getAdaptersetCurrentItem

0
    } 
 
    @Override 
    public void setCurrentItem(int item) {
	// offset the current item to ensure there is space to scroll 
	item = getOffsetAmount() + (item % getAdapter().getCount());
	super.setCurrentItem(item);
 
    } 
 
    private int getOffsetAmount() { 
	if (getAdapter() instanceof InfinitePagerAdapter) { 
	    InfinitePagerAdapter infAdapter = (InfinitePagerAdapter) getAdapter();
	    // allow for 100 back cycles from the beginning 
	    // should be enough to create an illusion of infinity 
	    // warning: scrolling to very high values (1,000,000+) results in 
	    // strange drawing behaviour 
	    return infAdapter.getRealCount() * 100;
	} else { 
	    return 0; 
Stop searching for code, let great code find you!  Add Codota to your java IDE