FragmentTransaction.SetReorderingAllowed(Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets whether or not to allow optimizing operations within and across transactions.
[Android.Runtime.Register("setReorderingAllowed", "(Z)Landroid/app/FragmentTransaction;", "GetSetReorderingAllowed_ZHandler", ApiSince=26)]
public abstract Android.App.FragmentTransaction? SetReorderingAllowed (bool reorderingAllowed);
[<Android.Runtime.Register("setReorderingAllowed", "(Z)Landroid/app/FragmentTransaction;", "GetSetReorderingAllowed_ZHandler", ApiSince=26)>]
abstract member SetReorderingAllowed : bool -> Android.App.FragmentTransaction
Parameters
- reorderingAllowed
- Boolean
true
to enable optimizing out redundant operations
or false
to disable optimizing out redundant
operations on this transaction.
Returns
- Attributes
Remarks
Sets whether or not to allow optimizing operations within and across transactions. This will remove redundant operations, eliminating operations that cancel. For example, if two transactions are executed together, one that adds a fragment A and the next replaces it with fragment B, the operations will cancel and only fragment B will be added. That means that fragment A may not go through the creation/destruction lifecycle.
The side effect of removing redundant operations is that fragments may have state changes out of the expected order. For example, one transaction adds fragment A, a second adds fragment B, then a third removes fragment A. Without removing the redundant operations, fragment B could expect that while it is being created, fragment A will also exist because fragment A will be removed after fragment B was added. With removing redundant operations, fragment B cannot expect fragment A to exist when it has been created because fragment A's add/remove will be optimized out.
It can also reorder the state changes of Fragments to allow for better Transitions. Added Fragments may have Fragment#onCreate(Bundle)
called before replaced Fragments have Fragment#onDestroy()
called.
The default is false
for applications targeting version versions prior to O and true
for applications targeting O and later.
Java documentation for android.app.FragmentTransaction.setReorderingAllowed(boolean)
.
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.