Android 12 Developer Preview is here! Try it out, and give us your feedback!

FragmentTransaction

abstract class FragmentTransaction
kotlin.Any
   ↳ androidx.fragment.app.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 Int

Bit mask that is set for all enter transitions.

static Int

Bit mask that is set for all exit transitions.

static Int

Fragment is being removed from the stack

static 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 Int

Fragment is being added onto the stack

static Int

No animation for transition.

static Int

Not set up for a transition.

Public constructors

Public methods
FragmentTransaction
add(@NonNull fragmentClass: Class<out Fragment!>, @Nullable args: Bundle?, @Nullable tag: String?)

Calls add(int, Class, Bundle, String) with a 0 containerViewId.

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

Calls add(int, Fragment, String) with a 0 containerViewId.

FragmentTransaction
add(@IdRes containerViewId: Int, @NonNull fragmentClass: Class<out Fragment!>, @Nullable args: Bundle?)

Calls add(int, Class, Bundle, String) with a null tag.

open FragmentTransaction
add(@IdRes containerViewId: Int, @NonNull fragment: Fragment)

Calls add(int, Fragment, String) with a null tag.

FragmentTransaction
add(@IdRes containerViewId: Int, @NonNull fragmentClass: Class<out Fragment!>, @Nullable args: Bundle?, @Nullable tag: String?)

Add a fragment to the activity state.

open FragmentTransaction
add(@IdRes containerViewId: Int, @NonNull fragment: Fragment, @Nullable tag: String?)

Add a fragment to the activity state.

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

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

open FragmentTransaction
addToBackStack(@Nullable name: String?)

Add this transaction to the back stack.

open FragmentTransaction
attach(@NonNull fragment: Fragment)

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

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 Unit

Commits this transaction synchronously.

abstract Unit

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

open FragmentTransaction
detach(@NonNull fragment: Fragment)

Detach the given fragment from the UI.

open FragmentTransaction

Disallow calls to addToBackStack(String).

open FragmentTransaction
hide(@NonNull fragment: Fragment)

Hides an existing fragment.

open Boolean

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

open Boolean

open FragmentTransaction
remove(@NonNull fragment: Fragment)

Remove an existing fragment.

FragmentTransaction
replace(@IdRes containerViewId: Int, @NonNull