ViewPager:对ExecutePendingTransaction的递归条目?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (32)

在ViewPager中有一个ViewPager,得到了这个异常

09-07 18:30:26.392: ERROR/AndroidRuntime(841): FATAL EXCEPTION: main
    java.lang.IllegalStateException: Recursive entry to executePendingTransactions
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1331)
    at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:422)
    at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:86)
    at android.support.v4.view.ViewPager.populate(ViewPager.java:453)
    at android.support.v4.view.ViewPager.onAttachedToWindow(ViewPager.java:563)
    at android.view.View.dispatchAttachedToWindow(View.java:7974)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1857)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1862)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1862)
    at android.view.ViewGroup.addViewInner(ViewGroup.java:2968)
    at android.view.ViewGroup.addView(ViewGroup.java:2824)
    at android.support.v4.view.ViewPager.addView(ViewPager.java:537)
    at android.view.ViewGroup.addView(ViewGroup.java:2781)
    at android.view.ViewGroup.addView(ViewGroup.java:2761)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:848)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1041)
    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:616)
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1359)
    at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:422)
    at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:86)
    at android.support.v4.view.ViewPager.populate(ViewPager.java:453)
    at android.support.v4.view.ViewPager.onAttachedToWindow(ViewPager.java:563)
    at android.view.View.dispatchAttachedToWindow(View.java:7974)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1857)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1862)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1862)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1862)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1862)
    at android.view.ViewRoot.performTraversals(ViewRoot.java:726)
    at android.view.ViewRoot.handleMessage(ViewRoot.java:1944)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:126)
    at android.app.ActivityThread.main(ActivityThread.java:3997)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:491)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
    at dalvik.system.NativeStart.main(Native Method)

提问于
用户回答回答于

最近,遇到了同样的问题

新版本的SupportLibrary v4(当然是Android4.2)解决了这个问题

用户回答回答于

新版本支持库v4(当然是Android4.2)可以简单地解决这个问题

public CustomFragmentPagerAdapter(android.support.v4.app.Fragment fragment)
{
    super(fragment.getChildFragmentManager());

    // write your code here
}

扫码关注云+社区