本文整理汇总了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();
}
}