Code example for FragmentTransaction

Methods: add, attach, remove

0
			if (!cls.equals(SamplePagerFragment.class)) {
				return; 
			} 
			// reconstruct the SamplePagerFragment 
			// remove it 
			ft.remove(f);
			// create a new one 
			f = Fragment.instantiate(activity, cls.getName());
			ft.add(containerId, f, /* tag */ null);
			// and reattach 
			ft.attach(f);
		} 
		/** 
		 * Called when a tab exits the chosen state. 
		 */ 
		public void onTabUnselected(Tab tab, FragmentTransaction ft) {
			// when a tab is unselected 
			if (f == null) {
				return; 
			} 
			ft.detach(f);