Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android系統教程 >> Android開發教程 >> Android錯誤:ava.lang.IllegalStateException

Android錯誤:ava.lang.IllegalStateException

編輯:Android開發教程

Android錯誤:ava.lang.IllegalStateException: Recursive entry to executePendingTransactions

錯誤

java.lang.IllegalStateException: Recursive entry to executePendingTransactions
     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
     at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
     at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
     at android.support.v4.view.ViewPager.populate(ViewPager.java:1012)
     at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:523)
     at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:495)
     at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:1221)
     at android.view.View.dispatchRestoreInstanceState(View.java:9966)
     at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2617)
     at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
     at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
     at android.view.View.restoreHierarchyState(View.java:9944)
     at android.support.v4.app.Fragment.restoreViewState(Fragment.java:417)
     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:933)
     at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1264)
     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:672)
     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
     at android.os.Handler.handleCallback(Handler.java:608)
     at android.os.Handler.dispatchMessage(Handler.java:92)
     at android.os.Looper.loop(Looper.java:156)
     at android.app.ActivityThread.main(ActivityThread.java:4987)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:511)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
     at dalvik.system.NativeStart.main(Native Method)

第一次使用沒有問題(add),第二次使用時就報這個錯(attach)。

場景

嵌套Fragment使用(最外層FragmentActivity,Fragment中使用ViewPager再嵌套Fragment使用)

解決

嵌套Fragment設置PageAdapter時要使用getChildFragmentManager。

作者:cnblogs 農民伯伯

查看本欄目更多精彩內容:http://www.bianceng.cn/OS/extra/

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved