replace

inline fun <F : Fragment> FragmentTransaction.replace(@IdRes containerViewId: Int, tag: String? = null, args: Bundle? = null): FragmentTransaction

Replace an existing fragment that was added to a container. This is essentially the same as calling remove for all currently added fragments that were added with the same containerViewId and then add with the same arguments given here.

The new fragment to place in the container will be created via the FragmentFactory of the FragmentManager.

Return

Returns the same FragmentTransaction instance.

Parameters

containerViewId

Identifier of the container whose fragment(s) are to be replaced.

tag

Optional tag name for the fragment, to later retrieve the fragment with FragmentManager.findFragmentByTag.

args

Optional arguments to be set on the fragment.