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
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
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.
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.