Google 致力于为黑人社区推动种族平等。查看具体举措

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 fragmentClass: Class<out Fragment!>, @Nullable args: Bundle?)

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

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

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

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

Replace an existing fragment that was added to a container.

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

Replace an existing fragment that was added to a container.

open FragmentTransaction
runOnCommit(@NonNull runnable: Runnable)

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

open FragmentTransaction
setAllowOptimization(allowOptimization: Boolean)

open FragmentTransaction
setBreadCrumbShortTitle(@StringRes res: Int)

Set the short title to show as a bread crumb when this transaction is on the back stack.

open FragmentTransaction

Like setBreadCrumbShortTitle(int) but taking a raw string; this method is not recommended, as the string can not be changed later if the locale changes.

open FragmentTransaction
setBreadCrumbTitle(@StringRes res: Int)

Set the full title to show as a bread crumb when this transaction is on the back stack.

open FragmentTransaction
setBreadCrumbTitle(@Nullable text: CharSequence?)

Like setBreadCrumbTitle(int) but taking a raw string; this method is not recommended, as the string can not be changed later if the locale changes.

open FragmentTransaction
setCustomAnimations(@AnimatorRes @AnimRes enter: Int, @AnimatorRes @AnimRes exit: Int)

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

open FragmentTransaction
setCustomAnimations(@AnimatorRes @AnimRes enter: Int, @AnimatorRes @AnimRes exit: Int, @AnimatorRes @AnimRes popEnter: Int, @AnimatorRes @AnimRes popExit: Int)

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

open FragmentTransaction
setMaxLifecycle(@NonNull fragment: Fragment, @NonNull state: Lifecycle.State)

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

open FragmentTransaction
setPrimaryNavigationFragment(@Nullable fragment: Fragment?)

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

open FragmentTransaction
setReorderingAllowed(reorderingAllowed: Boolean)

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

open FragmentTransaction
setTransition(transition: Int)

Select a standard transition animation for this transa