本文整理匯總了Java中android.app.FragmentTransaction.detach方法的典型用法代碼示例。如果您正苦於以下問題:Java FragmentTransaction.detach方法的具體用法?Java FragmentTransaction.detach怎麽用?Java FragmentTransaction.detach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.FragmentTransaction
的用法示例。
在下文中一共展示了FragmentTransaction.detach方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onAttachView
import android.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
protected void onAttachView(@NonNull View view) {
super.onAttachView(view);
//noinspection ConstantConditions
FragmentManager fm = getActivity().getFragmentManager();
Fragment fragment = fm.findFragmentByTag(getFragmentTag());
if (fragment == null) {
fragment = onCreateFragment();
fm.beginTransaction().add(getContainerId(), fragment, getFragmentTag()).commit();
} else {
FragmentTransaction transaction = fm.beginTransaction();
// transaction.attach() may not work if the the fragment isn't detached
if (!fragment.isDetached()) {
transaction.detach(fragment);
}
transaction.attach(fragment).commit();
}
}
示例2: detach
import android.app.FragmentTransaction; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void detach(Fragment fragment,
FragmentTransaction currTransaction) {
currTransaction.detach(fragment);
}
示例3: onTabUnselected
import android.app.FragmentTransaction; //導入方法依賴的package包/類
/**
* @brief Method called when the tab is unselected
* @param tab
* @param ft
* @details Method called when the tab is unselected
*/
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null) {
// Detach the fragment, because another one is being attached
ft.detach(mFragment);
}
}
示例4: reloadFragment
import android.app.FragmentTransaction; //導入方法依賴的package包/類
public static void reloadFragment(FragmentManager fragmentManager, Fragment fragment, int containViewId) {
if (fragment != null){
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.setTransition(-1);
// ft.replace(containViewId, fragment);
ft.detach(fragment);
ft.attach(fragment);
ft.commitAllowingStateLoss();
}
}