gpt4 book ai didi

android - FragmentManager : moveToState: Fragment state for GridFragment{. ..} 未内联更新;预期状态 1 找到 0

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:08:08 24 4
gpt4 key购买 nike

我有一个简单的 Activity 和 Retained Fragment,就像 Alex Lockwood blog post example .

我的 Activity 在 onCreate() 中是这样的:

FragmentManager fm = getSupportFragmentManager();
retainedFragment = (GridFragment) fm.findFragmentByTag(RETAINED_FRAGMENT_TAG);

// If the Fragment is non-null, then it is currently being
// retained across a configuration change.
if (retainedFragment == null) {
retainedFragment = new GridFragment();
fm.beginTransaction().add(retainedFragment, RETAINED_FRAGMENT_TAG).commit();
}else{
list = retainedFragment.getList();
System.out.println(list.size());//OUTPUT 12
}

我的 Fragments' onAttach() 是:

 @Override
public void onAttach(Context activity) {
super.onAttach(activity);
mCallbacks = (TaskCallbacks) activity;
System.out.println("here"); //OUTPUT here
}

现在,在每次屏幕旋转时,我都会得到非常奇怪的输出:

I/System.out: here

W/FragmentManager: moveToState: Fragment state for GridFragment{95fc9db #0 retained_tag} not updated inline; expected state 1 found 0

I/System.out: 12

在我的输入之间那个奇怪的警告来自哪里?如何处理?提前致谢!

最佳答案

此消息无关紧要,支持库 v24.0.0 中删除了额外的日志这是官方开发者answer :

For the curious, FragmentManager.moveToState now updates the new fragment state as it goes rather than at the end after all of the state change phases have completed. This fixed several interesting bugs around using the child fragment manager and executePendingTransactions from within one of the parent fragment's lifecycle callbacks.

One of the state transitions as we're bringing a fragment up is a no-op that wasn't getting the state updated inline, and the log you're seeing is announcing that we did it at the end instead, exactly as we would have prior to 23.2.

关于android - FragmentManager : moveToState: Fragment state for GridFragment{. ..} 未内联更新;预期状态 1 找到 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37125731/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com