android – executePendingTransactions()总是必要的吗?

前端之家收集整理的这篇文章主要介绍了android – executePendingTransactions()总是必要的吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这更像是一个理论问题.

我有一种情况,我的应用程序崩溃与片段交换与executePendingTransactions()调用,并没有它工作正常.

我的问题是,如果我不调用executePendingTransactions(),一般会出现什么问题?

据我所知,没有这种方法,片段交换可能不会立即发生,虽然我从未经历过这种情况.

解决方法

除非您执行的操作取决于事务,否则不需要它.从 API documentation,

After aFragmentTransactionis committed with
FragmentTransaction.commit(),it is scheduled to be executed asynchronously on the process’s main thread. If you want to immediately executing any such pending operations,you can call this function (only from the main thread) to do so. Note that all callbacks and other related behavior will be done from within this call,so be careful about where this is called from.

原文链接:https://www.f2er.com/android/315538.html

猜你在找的Android相关文章