FragmentTransactionKt

Added in 1.2.0

public final class FragmentTransactionKt


Summary

Public methods

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

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

static final @NonNull FragmentTransaction
<F extends Fragment> add(
    @NonNull FragmentTransaction receiver,
    @IdRes int containerViewId,
    String tag,
    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.

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

Replace an existing fragment that was added to a container.

Public methods

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

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

The new fragment to be added will be created via the FragmentFactory of the FragmentManager.

Parameters
@NonNull String tag

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

Bundle args

Optional arguments to be set on the fragment.

Returns
@NonNull FragmentTransaction

Returns the same FragmentTransaction instance.

public static final @NonNull FragmentTransaction <F extends Fragment> add(
    @NonNull FragmentTransaction receiver,
    @IdRes int containerViewId,
    String tag,
    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.

The new fragment to be added will be created via the FragmentFactory of the FragmentManager.

Parameters
@IdRes int containerViewId

Identifier of the container this fragment is to be placed in.

String tag

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

Bundle args

Optional arguments to be set on the fragment.

Returns
@NonNull FragmentTransaction

Returns the same FragmentTransaction instance.

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

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.

Parameters
@IdRes int containerViewId

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

String tag

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

Bundle args

Optional arguments to be set on the fragment.

Returns
@NonNull FragmentTransaction

Returns the same FragmentTransaction instance.