我有一组碎片。每个片段都包含recyclerview,而recyclelerview将viewpager作为第一行。
现在在这组片段中,当我从一个片段切换到另一个片段时崩溃以下是它的异常日志
logcat的
E/UncaughtException: java.lang.IllegalArgumentException: No view found for id 0x7f1000ef (:id/viewPagerBanners) for fragment MainBannerFragmentNew{a1564b5 #0 id=0x7f1000ef}
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1293)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2888)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2204)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1326)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2888)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2204)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1326)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
我将getChildFragmentManager传递给Viewpager适配器,我正在使用FragmentStatePagerAdapter
Inside RecyclerView适配器我将适配器附加到viewpager,如下所示
switch (holder.getItemViewType()) {
case TYPE_BANNER:
if (((BannerHolder) holder).viewPager.getAdapter() == null) {
((BannerHolder) holder).viewPager.setAdapter(new CarouselAdapter(fragmentManager, carouselItems));