Code example for FragmentTransaction

Methods: attach

0
    public void onTabSelected(Tab tab, FragmentTransaction ft) {
        if (mFragment == null) {
            mFragment = Fragment.instantiate(mActivity, mClass.getName(), mArgs);
            ft.add(android.R.id.content, mFragment, mTag);
        } else { 
            ft.attach(mFragment);
        } 
    } 
 
    public void onTabUnselected(Tab tab, FragmentTransaction ft) {
        if (mFragment != null) {
        	if (mAlwaysReload) {
                ft.remove(mFragment);
                mFragment = null;
        	} else { 
        		ft.detach(mFragment);
        	} 
        } 
    } 
 
    public void onTabReselected(Tab tab, FragmentTransaction ft) {}