Share via


FragmentTransaction.Replace Method

Definition

Overloads

Replace(Int32, Fragment)

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

Replace(Int32, Fragment, String)

Replace an existing fragment that was added to a container.

Replace(Int32, Fragment)

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

[Android.Runtime.Register("replace", "(ILandroid/app/Fragment;)Landroid/app/FragmentTransaction;", "GetReplace_ILandroid_app_Fragment_Handler")]
public abstract Android.App.FragmentTransaction? Replace (int containerViewId, Android.App.Fragment? fragment);
[<Android.Runtime.Register("replace", "(ILandroid/app/Fragment;)Landroid/app/FragmentTransaction;", "GetReplace_ILandroid_app_Fragment_Handler")>]
abstract member Replace : int * Android.App.Fragment -> Android.App.FragmentTransaction

Parameters

containerViewId
Int32
fragment
Fragment

Returns

Attributes

Remarks

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

Java documentation for android.app.FragmentTransaction.replace(int, android.app.Fragment).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Replace(Int32, Fragment, String)

Replace an existing fragment that was added to a container.

[Android.Runtime.Register("replace", "(ILandroid/app/Fragment;Ljava/lang/String;)Landroid/app/FragmentTransaction;", "GetReplace_ILandroid_app_Fragment_Ljava_lang_String_Handler")]
public abstract Android.App.FragmentTransaction? Replace (int containerViewId, Android.App.Fragment? fragment, string? tag);
[<Android.Runtime.Register("replace", "(ILandroid/app/Fragment;Ljava/lang/String;)Landroid/app/FragmentTransaction;", "GetReplace_ILandroid_app_Fragment_Ljava_lang_String_Handler")>]
abstract member Replace : int * Android.App.Fragment * string -> Android.App.FragmentTransaction

Parameters

containerViewId
Int32

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

fragment
Fragment

The new fragment to place in the container.

tag
String

Optional tag name for the fragment, to later retrieve the fragment with FragmentManager#findFragmentByTag(String) FragmentManager.findFragmentByTag(String).

Returns

Returns the same FragmentTransaction instance.

Attributes

Remarks

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

Java documentation for android.app.FragmentTransaction.replace(int, android.app.Fragment, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to