错误代码如下:
06-20 09:56:21.366: E/AndroidRuntime(1650): FATAL EXCEPTION: main
06-20 09:56:21.366: E/AndroidRuntime(1650): java.lang.IllegalStateException: Recursive entry to executePendingTransactions
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1388)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:139)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.view.ViewPager.populate(ViewPager.java:804)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:433)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:405)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:898)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.view.View.dispatchRestoreInstanceState(View.java:12284)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2620)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2626)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.view.View.restoreHierarchyState(View.java:12262)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.app.Fragment.restoreViewState(Fragment.java:407)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:897)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.os.Handler.handleCallback(Handler.java:730)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.os.Handler.dispatchMessage(Handler.java:92)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.os.Looper.loop(Looper.java:137)
06-20 09:56:21.366: E/AndroidRuntime(1650): at android.app.ActivityThread.main(ActivityThread.java:5103)
06-20 09:56:21.366: E/AndroidRuntime(1650): at java.lang.reflect.Method.invokeNative(Native Method)
06-20 09:56:21.366: E/AndroidRuntime(1650): at java.lang.reflect.Method.invoke(Method.java:525)
06-20 09:56:21.366: E/AndroidRuntime(1650): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
06-20 09:56:21.366: E/AndroidRuntime(1650): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-20 09:56:21.366: E/AndroidRuntime(1650): at dalvik.system.NativeStart.main(Native Method)
首先我第一次切换到那个Fragment是正常的,但是第二次在切换过去就报错了。
我要是不给里面的ViewPage设置适配器的话就没问题。
希望有人能给出解决方案
你的fragment没问题,是你的适配器绑定数据过程中有问题
绑定数据没问题的,要不然第一次加载fragment不就报错了? 我这个是第二次加载才报错的。(fragment嵌套fragment)