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.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...