Android ViewPager:没有嵌套片段的executePendingTransactions的递归入口

时间:2014-06-10 16:24:56

标签: android android-fragments android-viewpager

我在我的应用程序上使用ViewPager,除了显示最后一个片段之外它工作正常。 显示该片段时,我收到以下错误:

java.lang.IllegalStateException: Recursive entry to executePendingTransactions
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1388)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:139)
at android.support.v4.view.ViewPager.populate(ViewPager.java:804)
at android.support.v4.view.ViewPager.completeScroll(ViewPager.java:1280)
at android.support.v4.view.ViewPager.computeScroll(ViewPager.java:1176)
at android.view.View.getDisplayList(View.java:14182)
at android.view.View.getDisplayList(View.java:14239)
at android.view.View.draw(View.java:15017)
at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3135)
at android.view.View.getDisplayList(View.java:14192)
at android.view.View.getDisplayList(View.java:14239)
at android.view.View.draw(View.java:15017)
at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3135)
at android.view.View.draw(View.java:15306)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at android.view.View.getDisplayList(View.java:14197)
at android.view.View.getDisplayList(View.java:14239)
at android.view.View.draw(View.java:15017)
at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3135)
at android.view.View.getDisplayList(View.java:14192)
at android.view.View.getDisplayList(View.java:14239)
at android.view.View.draw(View.java:15017)
at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3135)
at android.view.View.draw(View.java:15306)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2568)
at android.view.View.getDisplayList(View.java:14197)
at android.view.View.getDisplayList(View.java:14239)
at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2705)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2571)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2143)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1234)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6467)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)

阅读几个stackoverflow问题,最常见的原因是嵌套片段。但是,这不是我的情况,我的片段中没有一个包含子片段。 要填充ViewPager,我使用PageAdapter,如下所示:

    // step 1: create the fragment list
    List<Fragment> fragments = new Vector<Fragment>();
    // wt1
    WalkthroughFragment fragment = new WalkthroughFragment_();
    fragment.setImageBottomId(R.drawable.wt1);
    fragment.setTextId(R.string.walkthrough_1);
    fragment.setButtonId(R.string.walkthrough_skip);
    fragments.add(fragment);
    // wt2
    fragment = new WalkthroughFragment_();
    fragment.setImageBottomId(R.drawable.wt2);
    fragment.setTextId(R.string.walkthrough_2);
    fragments.add(fragment);
    // login
    LoginSocialFragment social = new LoginSocialFragment_();
    fragments.add(social);

    // step 2: create the adapter for the view pager
    this.pager.setAdapter(new MyPageAdapter(getSupportFragmentManager(), fragments));
    // step 3: set the default item as the first one
    //TODO: use preferences to see whether should be the last one
    this.pager.setCurrentItem(0);
    //step 4: bind the pager to the indicator
    this.indicator.setViewPager(this.pager);
    this.indicator.notifyDataSetChanged();

然后我不在代码的任何其他部分使用这些片段,也不再添加它们。 有什么想法吗?

2 个答案:

答案 0 :(得分:1)

它最终成为最后一个片段的问题。 当ViewPager加载该片段时,由于缺少jar,它会引发ClassDefNotFound异常。 然后,因为我正在重新加载活动,所以片段再次被实例化并且无法抛出我放在帖子上的异常。 因此,“递归进入executePendingTransactions”异常并不总是与嵌套片段有关。只是你知道:)。

答案 1 :(得分:0)

所以,我遇到了同样的问题。 根本没有嵌套片段,甚至没有ViewPager。 突然之间,我的应用程序工作正常。

在看到您对问题的答案后,我将“日志过滤器”更改为“所选应用程序中的警告”。 事实证明,一个简单的&#34;阵列超出边界的例外&#34; (警告)被扔在片段中的某个地方。修复之后,&#34;递归进入executePendingTransactions&#34;停止。

我没有研究或任何事情。但似乎任何能够制造碎片的东西都会冻结#34;可能是这个的原因。 如果有人遇到此问题,我强烈建议我做我所做的事情以找到问题(更改日志过滤器)。