Code example for FragmentPagerAdapter

Methods: instantiateItem

0
		@Override 
		public Object instantiateItem(final ViewGroup container, final int position) {
			if (DBG)
				Log.d(LOG_TAG, "instantiateItem " + position);
 
			final Fragment fragment = (Fragment) super.instantiateItem(container, position);
			// fragment.setRetainInstance(true); 
			mFragmentsTags[position] = fragment.getTag();
			return fragment;
		} 
 
		@Override 
		public Fragment getItem(final int position) {
			if (DBG)
				Log.d(LOG_TAG, "getItem " + position + " : " + mClasses[position]);
 
			final Fragment fragment = Fragment.instantiate(FragmentsActivity.this, mClasses[position]);
			// fragment.setRetainInstance(true); 
			return fragment;
		}