Fragment fragmentCurr = null;
private void switchFragment(Fragment fragmentTo) {
FragmentTransaction transaction = this.getSupportFragmentManager().beginTransaction();
if(fragmentCurr == fragmentTo) {
return;
}
if (fragmentTo.isAdded()) {
transaction.show(fragmentTo);
} else {
transaction.add(R.id.fragment_view, fragmentTo).show(fragmentTo);
}
if (null != fragmentCurr) {
transaction.hide(fragmentCurr);
}
transaction.commit();
fragmentCurr = fragmentTo;
}
fragment 切换 show/hide
猜你喜欢
转载自blog.csdn.net/liuyj_vv/article/details/88735502
今日推荐
周排行