问题
I'm having problem with view pager which is inside of some fragment. To work with view pager I'm using FragmentPagerAdapter. And sure I'm getting java.lang.IllegalStateException: Recursive entry to executePendingTransactions exception when trying to run my app.
Most people say it's impossible to have FragmentPagerAdapter inside other fragment, so I'm sorry if this question is invalid. I was just hoping that maybe someone has some fresh ideas about this problem and its possible solution.
P.S. I've got an advice to set adapter inside of AsyncTask (I can clarify this case if someone needs it), but this solution has some bugs related with restoring such fragment state, so it's working for me.
回答1:
Starting with Android 4.2, you can use nested fragments. The Android support library now also includes support for this, so you can use it with older Android versions.
The basic pattern looks like this:
Fragment videoFragment = new VideoPlayerFragment();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.add(R.id.video_fragment, videoFragment).commit();
来源:https://stackoverflow.com/questions/9925467/viewpager-inside-fragment-issue