2012-07-26 5 views

Respuesta

8

fragmentTransaction.hide(fragment) hace

public void hideFragment(Fragment fragment, int transition, int transitionStyle) { 
    if (DEBUG) Log.v(TAG, "hide: " + fragment); 
    if (!fragment.mHidden) { 
     fragment.mHidden = true; 
     if (fragment.mView != null) { 
      Animator anim = loadAnimator(fragment, transition, true, 
        transitionStyle); 
      if (anim != null) { 
       anim.setTarget(fragment.mView); 
       // Delay the actual hide operation until the animation finishes, otherwise 
       // the fragment will just immediately disappear 
       final Fragment finalFragment = fragment; 
       anim.addListener(new AnimatorListenerAdapter() { 
        @Override 
        public void onAnimationEnd(Animator animation) { 
         if (finalFragment.mView != null) { 
          finalFragment.mView.setVisibility(View.GONE); 
         } 
        } 
       }); 
       anim.start(); 
      } else { 
       fragment.mView.setVisibility(View.GONE); 
      } 
     } 
     if (fragment.mAdded && fragment.mHasMenu && fragment.mMenuVisible) { 
      mNeedMenuInvalidate = true; 
     } 
     fragment.onHiddenChanged(true); 
    } 
} 

por lo que más o menos la misma pero

  • apoya la animación
  • apoya backstack
  • establece el View regresado Fragment#onCreateView()-GONE en lugar del contenedor
  • se ocupa del menú si el fragmento se agrega allí