Code example for FragmentPagerAdapter

Methods: instantiateItem

    public Fragment getCachedItem(int position) {
        // Do we already have this fragment? 
    	if (!mSingletonMap.containsKey(position)) {
    		Log.i(getClass().getName(), "Fragment cache miss");
	        Fragment fragment = (Fragment) instantiateItem(mViewPager, position);
	        mSingletonMap.put(position, fragment);
	        return fragment;
    	} else { 
    		Log.i(getClass().getName(), "Fragment cache hit");
    		return mSingletonMap.get(position);
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    public void onPageSelected(int position) {
Connect your IDE to all the code out there  Get Codota for Java