FragmentTransaction


public abstract class FragmentTransaction


Static library support version of the framework's android.app.FragmentTransaction. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview.

Summary

Constants

static final int

Bit mask that is set for all enter transitions.

static final int

Bit mask that is set for all exit transitions.

static final int

Fragment is being removed from the stack

static final int

Fragment should simply fade in or out; that is, no strong navigation associated with it except that it is appearing or disappearing for some reason.

static final int

Fragment is being removed from the stack with Activity close transition.

static final int

Fragment is being added onto the stack with Activity open transition.

static final int

Fragment is being added onto the stack

static final int

No animation for transition.

static final int

Not set up for a transition.

Public constructors

This method is deprecated.

You should not instantiate a FragmentTransaction except via beginTransaction.

Public methods

@NonNull FragmentTransaction
add(@IdRes int containerViewId, @NonNull Fragment fragment)

Calls add with a null tag.

@NonNull FragmentTransaction
add(@NonNull Fragment fragment, @Nullable String tag)

Calls add with a 0 containerViewId.

final @NonNull FragmentTransaction
add(
    @NonNull ViewGroup container,
    @NonNull Fragment fragment,
    @Nullable String tag
)

Add a fragment to the activity state.

final @NonNull FragmentTransaction
add(
    @IdRes int containerViewId,
    @NonNull Class<Fragment> fragmentClass,
    @Nullable Bundle args
)

Calls add with a null tag.

@NonNull FragmentTransaction
add(
    @IdRes int containerViewId,
    @NonNull Fragment fragment,
    @Nullable String tag
)

Add a fragment to the activity state.

final @NonNull FragmentTransaction
add(
    @NonNull Class<Fragment> fragmentClass,
    @Nullable Bundle args,
    @Nullable String tag
)

Calls add with a 0 containerViewId.

final @NonNull FragmentTransaction
add(
    @IdRes int containerViewId,
    @NonNull Class<Fragment> fragmentClass,
    @Nullable Bundle args,
    @Nullable String tag
)

Add a fragment to the activity state.

@NonNull FragmentTransaction
addSharedElement(@NonNull View sharedElement, @NonNull String name)

Used with custom Transitions to map a View from a removed or hidden Fragment to a View from a shown or added Fragment.

@NonNull FragmentTransaction

Add this transaction to the back stack.

@NonNull FragmentTransaction
attach(@NonNull Fragment fragment)

Re-attach a fragment after it had previously been detached from the UI with detach.

abstract int

Schedules a commit of this transaction.

abstract int

Like commit but allows the commit to be executed after an activity's state is saved.

abstract void

Commits this transaction synchronously.

abstract void

Like commitNow but allows the commit to be executed after an activity's state is saved.

@NonNull FragmentTransaction
detach(@NonNull Fragment fragment)

Detach the given fragment from the UI.

@NonNull FragmentTransaction

Disallow calls to addToBackStack.

@NonNull FragmentTransaction
hide(@NonNull Fragment fragment)

Hides an existing fragment.

boolean

Returns true if this FragmentTransaction is allowed to be added to the back stack.

boolean
@NonNull FragmentTransaction
remove(@NonNull Fragment fragment)

Remove an existing fragment.

@NonNull FragmentTransaction
replace(@IdRes int containerViewId, @NonNull Fragment fragment)

Calls replace with a null tag.

final @NonNull FragmentTransaction
replace(
    @IdRes int containerViewId,
    @NonNull Class<Fragment> fragmentClass,
    @Nullable Bundle args
)

Calls replace with a null tag.

@NonNull FragmentTransaction
replace(
    @IdRes int containerViewId,
    @NonNull Fragment fragment,
    @Nullable String tag
)

Replace an existing fragment that was added to a container.

final @NonNull FragmentTransaction
replace(
    @IdRes int containerViewId,
    @NonNull Class<Fragment> fragmentClass,
    @Nullable Bundle args,
    @Nullable String tag
)

Replace an existing fragment that was added to a container.

@NonNull FragmentTransaction

Add a Runnable to this transaction that will be run after this transaction has been committed.

@NonNull FragmentTransaction
setAllowOptimization(boolean allowOptimization)

This method is deprecated.

This has been renamed setReorderingAllowed.

@NonNull FragmentTransaction

This method is deprecated.

Store breadcrumb short titles separately from fragment transactions.

@NonNull FragmentTransaction

This method is deprecated.

Store breadcrumb short titles separately from fragment transactions.

@NonNull FragmentTransaction

This method is deprecated.

Store breadcrumb titles separately from fragment transactions.

@NonNull FragmentTransaction

This method is deprecated.

Store breadcrumb titles separately from fragment transactions.

@NonNull FragmentTransaction
setCustomAnimations(
    @AnimatorRes @AnimRes int enter,
    @AnimatorRes @AnimRes int exit
)

Set specific animation resources to run for the fragments that are entering and exiting in this transaction.

@NonNull FragmentTransaction
setCustomAnimations(
    @AnimatorRes @AnimRes int enter,
    @AnimatorRes @AnimRes int exit,
    @AnimatorRes @AnimRes int popEnter,
    @AnimatorRes @AnimRes int popExit
)

Set specific animation resources to run for the fragments that are entering and exiting in this transaction.

@NonNull FragmentTransaction

Set a ceiling for the state of an active fragment in this FragmentManager.

@NonNull FragmentTransaction

Set a currently active fragment in this FragmentManager as the primary navigation fragment.

@NonNull FragmentTransaction
setReorderingAllowed(boolean reorderingAllowed)

Sets whether or not to allow optimizing operations within and across transactions.

@NonNull FragmentTransaction
setTransition(int transition)

Select a standard transition animation for this transaction.

@NonNull FragmentTransaction

This method is deprecated.

The desired functionality never worked correctly.

@NonNull FragmentTransaction
show(@NonNull Fragment fragment)

Shows a previously hidden fragment.

Extension functions

final @NonNull FragmentTransaction
<F extends Fragment> FragmentTransactionKt.add(
    @NonNull FragmentTransaction receiver,
    @NonNull String tag,
    Bundle args
)

Add a fragment to the associated FragmentManager without adding the Fragment to any container view.

final @NonNull FragmentTransaction
<F extends Fragment> FragmentTransactionKt.add(
    @NonNull