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 @NonNull int

Bit mask that is set for all enter transitions.

static final @NonNull int

Bit mask that is set for all exit transitions.

static final @NonNull int

Fragment is being removed from the stack

static final @NonNull 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 @NonNull int

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

static final @NonNull int

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

static final @NonNull int

Fragment is being added onto the stack

static final @NonNull int

No animation for transition.

static final @NonNull int

Not set up for a transition.

Public constructors

This method is deprecated.

You should not instantiate a FragmentTransaction except via beginTransaction.

Public methods

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

Calls add with a 0 containerViewId.

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

Calls add with a 0 containerViewId.

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

Calls add with a null tag.

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

Calls add with a null tag.

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

Add a fragment to the activity state.

@NonNull FragmentTransaction
add(
    @IdRes @NonNull int containerViewId,
    @NonNull Fragment fragment,
    @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 @NonNull int

Schedules a commit of this transaction.

abstract @NonNull int

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

abstract @NonNull void

Commits this transaction synchronously.

abstract @NonNull 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.

@NonNull boolean

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

@NonNull boolean
@NonNull FragmentTransaction
remove(@NonNull Fragment fragment)

Remove an existing fragment.

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

Calls replace with a null tag.

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

Calls replace with a null tag.

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

Replace an existing fragment that was added to a container.

@NonNull FragmentTransaction
replace(
    @IdRes @NonNull int containerViewId,
    @NonNull Fragment fragment,
    @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(@NonNull 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 @NonNull int enter,
    @AnimatorRes @AnimRes @NonNull int exit
)

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

@NonNull FragmentTransaction
setCustomAnimations(
    @AnimatorRes @AnimRes @NonNull int enter,
    @AnimatorRes @AnimRes @NonNull int exit,
    @AnimatorRes @AnimRes @NonNull int popEnter,
    @AnimatorRes @AnimRes @NonNull 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(@NonNull boolean reorderingAllowed)

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

@NonNull FragmentTransaction

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,
    @IdRes int containerViewId,
    @Nullable String tag,
    @Nullable Bundle args
)

Add a fragment to the associated FragmentManager, inflating the Fragment's view into the container view specified by containerViewId, to later retrieve via FragmentManager.findFragmentById.

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

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

final @NonNull FragmentTransaction
<F extends Fragment> FragmentTransactionKt.replace(
    @NonNull FragmentTransaction receiver,
    @IdRes int containerViewId,
    @Nullable String tag,
    @Nullable Bundle args
)

Replace an existing fragment that was added to a container.

Constants

TRANSIT_ENTER_MASK

@NonNull
public static final @NonNull int TRANSIT_ENTER_MASK

Bit mask that is set for all enter transitions.

TRANSIT_EXIT_MASK

@NonNull
public static final @NonNull int TRANSIT_EXIT_MASK

Bit mask that is set for all exit transitions.

TRANSIT_FRAGMENT_CLOSE

@NonNull
public static final @NonNull int TRANSIT_FRAGMENT_CLOSE

Fragment is being removed from the stack

TRANSIT_FRAGMENT_FADE

@NonNull
public static final @NonNull int TRANSIT_FRAGMENT_FADE

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.

TRANSIT_FRAGMENT_MATCH_ACTIVITY_CLOSE

@NonNull
public static final @