GONE
addToBackStackとfragmentTransaction.hide(fragment)
は別にフラグメントを含むレイアウトの可視性の設定に主な違いはありますか?
4210 次
1 に答える
8
fragmentTransaction.hide(fragment)
します
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);
}
}
ですから、ほとんど同じですが、
- アニメーションをサポート
- バックスタックをサポート
- コンテナの代わりに、に
View
返されるFragment#onCreateView()
を設定しますGONE
- そこに追加されたsthをフラグメント化すると、メニューが処理されます
于 2012-08-29T18:20:13.747 に答える