Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalStateException #64

Open
V-sign opened this issue Oct 31, 2018 · 4 comments
Open

java.lang.IllegalStateException #64

V-sign opened this issue Oct 31, 2018 · 4 comments

Comments

@V-sign
Copy link

V-sign commented Oct 31, 2018

Fragment *** is not currently in the FragmentManager
请问这个问题如何解决?

@LuckyJayce
Copy link
Owner

LuckyJayce commented Oct 31, 2018

检查一下FragmentManager 是否用错了,
fragment里面的fragment的getChildFragmentManager()方法
Activity内的用Activity的的getSupportFragmentManager()方法

@V-sign
Copy link
Author

V-sign commented Nov 1, 2018

getChildFragmentManager()会导致这个问题
getSupportFragmentManager()会导致
java.lang.IllegalStateException: FragmentManager is already executing transactions
最后只能在 activity 里面加载 viewpager...

@baoti
Copy link

baoti commented Mar 25, 2019

@LuckyJayce 请问 FragmentListPageAdapter.finishUpdate 中为什么要调用 mFragmentManager.executePendingTransactions() 呢?
我不明白这里为什么和官方 support 库中的实现不同。

    public void finishUpdate(ViewGroup container) {
        if (mCurTransaction != null) {
            mCurTransaction.commitAllowingStateLoss();
            mCurTransaction = null;
            mFragmentManager.executePendingTransactions();
        }
    }

官方 support 包中的对应方法为:

    public void finishUpdate(@NonNull ViewGroup container) {
        if (this.mCurTransaction != null) {
            this.mCurTransaction.commitNowAllowingStateLoss();
            this.mCurTransaction = null;
        }
    }

@baoti
Copy link

baoti commented Mar 26, 2019

@LuckyJayce 我知道了,它们的行为是基本一致的。commitNowAllowingStateLoss() 也会立即执行当前 transaction。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants