ViewPager: Recursive entry to executePendingTransactions

最后都变了- 提交于 2019-11-27 13:01:14
Dmitry Ryadnenko

Recently I encountered the same problem and after a little investigation I was surprised to discover that you simply can't embed one fragment into another. Here you are executing one fragment transaction in another one. It's just not allowed.

New version of Support Library v4 (or Android 4.2, of course) resolves this problem. See the answer below.

Update getChildFragmentManager () added to tackle the above mentioned issue.

New version of Support Library v4 (or Android 4.2, ofcourse) resolve this problem much simply. For do this, simply do constructor of your custom FragmentPagerAdapter like this:

public CustomFragmentPagerAdapter(android.support.v4.app.Fragment fragment)
{
    super(fragment.getChildFragmentManager());

    // write your code here
}

This work because new Android version approve using nested Fragments

Jack

Refer to this. Display fragment viewpager within a fragment

It can be done, but has be done through an Asysnc as you have to let the first fragments transaction complete first. You can have fragments within fragments. I know because I have several projects doing it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!