ViewPager: Recursive entry to executePendingTransactions

前端 未结 3 1979
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 02:44

I have a ViewPager within a ViewPager and I am getting this exception

09-07 18:30:26.392: ERROR/AndroidRuntime(841): FATAL EXCEPTION: main
    java.lang.Ille         


        
相关标签:
3条回答
  • 2020-12-03 03:07

    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

    0 讨论(0)
  • 2020-12-03 03:12

    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.

    0 讨论(0)
  • 2020-12-03 03:14

    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.

    0 讨论(0)
提交回复
热议问题