Tag: fragmenttransaction

片段生命周期 – 显示/隐藏哪个方法?

我正在使用以下方法通过显示/隐藏片段(在我的NavigationDrawer)之间切换。 protected void showFragment(int container, Fragment fragment, String tag, String lastTag, boolean addToBackStack ) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); if ( lastTag != null && !lastTag.equals("")) { Fragment lastFragment = fragmentManager.findFragmentByTag( lastTag ); if ( lastFragment != null ) { transaction.hide( lastFragment ); } } if ( fragment.isAdded() ) { transaction.show( […]