Android ViewPager Fragment相互嵌套遇到的问题


在项目开发中要在主页中显示不同的页面Fragment,页面Fragment中又嵌套Viewpager,Viewpager添加的是Fragment,然后根据需求增减主页的页面个数时,发生如下异常。解决方法
将主页Fragment中嵌套的ViewPager的apdater设置为空
05-22 18:04:26.960 3869-3869/com.isport.tracker E/AndroidRuntime: FATAL EXCEPTION: main                                                                  Process: com.isport.tracker, PID: 3869                                                                  java.lang.IllegalArgumentException: No view found for id 0x7f0e01e2 (com.isport.tracker:id/fragment_exercise_pager) for fragment FragmentContent{b8c7d2f #0 id=0x7f0e01e2 android:switcher:2131624418:507}                                                                      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1292)                                                                      at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1523)                                                                      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1585)                                                                      at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2832)                                                                      at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2199)                                                                      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1323)                                                                      at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)                                                                      at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)                                                                      at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)                                                                      at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)                                                                      at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)                                                                      at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)                                                                      at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)                                                                      at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)                                                                      at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:540)                                                                      at com.isport.tracker.main.MainActivityGroup.updateFragmentUI(MainActivityGroup.java:220)                                                                      at com.isport.tracker.main.MainActivityGroup.access$000(MainActivityGroup.java:52)                                                                      at com.isport.tracker.main.MainActivityGroup$1.handleMessage(MainActivityGroup.java:99)                                                                      at android.os.Handler.dispatchMessage(Handler.java:102)                                                                      at android.os.Looper.loop(Looper.java:154)                                                                      at android.app.ActivityThread.main(ActivityThread.java:6692)                                                                      at java.lang.reflect.Method.invoke(Native Method)                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

智能推荐

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告