您好,登錄后才能下訂單哦!
// 初始化默認顯示的界面 if (purchaserHomeFragment == null) { purchaserHomeFragment = new PurchaserHomeFragment(); addFragment(purchaserHomeFragment); showFragment(purchaserHomeFragment); } else { showFragment(purchaserHomeFragment); } // 購物車界面 if (purchaserCarFragment == null) { purchaserCarFragment = new PurchaserCarFragment(); // 判斷當前界面是否隱藏,如果隱藏就進行添加顯示,false表示顯示,true表示當前界面隱藏 if (!purchaserCarFragment.isHidden()) { addFragment(purchaserCarFragment); showFragment(purchaserCarFragment); } } else { if (purchaserCarFragment.isHidden()) { showFragment(purchaserCarFragment); } } /** 添加fragment **/ public void addFragment(Fragment fragment) { FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction(); ft.add(R.id.fl_content, fragment); ft.commit(); } /** 顯示fragment **/ public void showFragment(Fragment fragment) { FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction(); // 判斷頁面是否已經創建,如果已經創建,那么就隱藏掉 if (purchaserHomeFragment != null) { ft.hide(purchaserHomeFragment); } if (purchaserTypeFragment != null) { ft.hide(purchaserTypeFragment); } if (purchaserOrderFragment != null) { ft.hide(purchaserOrderFragment); } if (purchaserCarFragment != null) { ft.hide(purchaserCarFragment); } ft.show(fragment); ft.commitAllowingStateLoss(); }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。