Partager via


FragmentTransaction.Commit Method

Definition

Schedules a commit of this transaction.

[Android.Runtime.Register("commit", "()I", "GetCommitHandler")]
public abstract int Commit ();
[<Android.Runtime.Register("commit", "()I", "GetCommitHandler")>]
abstract member Commit : unit -> int

Returns

Returns the identifier of this transaction's back stack entry, if #addToBackStack(String) had been called. Otherwise, returns a negative number.

Attributes

Remarks

Schedules a commit of this transaction. The commit does not happen immediately; it will be scheduled as work on the main thread to be done the next time that thread is ready.

<p class="note">A transaction can only be committed with this method prior to its containing activity saving its state. If the commit is attempted after that point, an exception will be thrown. This is because the state after the commit can be lost if the activity needs to be restored from its state. See #commitAllowingStateLoss() for situations where it may be okay to lose the commit.</p>

Java documentation for android.app.FragmentTransaction.commit().

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