Attempt to invoke virtual method 'int me.yokeyword.fragmentation.anim.FragmentAnimator.getEnter()' on a null object reference
See original GitHub issueviewpage 使用FragmentStatePagerAdapter,点击position-1出现
java.lang.NullPointerException: Attempt to invoke virtual method 'int me.yokeyword.fragmentation.anim.FragmentAnimator.getEnter()' on a null object reference at me.yokeyword.fragmentation.helper.internal.AnimatorHelper.initEnterAnim(AnimatorHelper.java:63) at me.yokeyword.fragmentation.helper.internal.AnimatorHelper.notifyChanged(AnimatorHelper.java:29) at me.yokeyword.fragmentation.helper.internal.AnimatorHelper.<init>(AnimatorHelper.java:24) at me.yokeyword.fragmentation.SupportFragmentDelegate.onCreate(SupportFragmentDelegate.java:117) at xxx.BaseFragment.onCreate(BaseFragment.java:69) at xxx.ChannelFragment.onCreate(ChannelFragment.java:80) at android.support.v4.app.Fragment.performCreate(Fragment.java:2246) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1377) at android.support.v4.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1187) at android.support.v4.app.FragmentTransition.calculateFragments(FragmentTransition.java:1070) at android.support.v4.app.FragmentTransition.startTransitions(FragmentTransition.java:115) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2374) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2332) at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2209) at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:649) at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:167) at android.support.v4.view.ViewPager.populate(ViewPager.java:1238) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:663) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:625) at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:606) at android.support.design.widget.TabLayout$ViewPagerOnTabSelectedListener.onTabSelected(TabLayout.java:2170) at android.support.design.widget.TabLayout.dispatchTabSelected(TabLayout.java:1165) at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1158) at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1128) at android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1427) at android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1537) at android.view.View$PerformClick.run(View.java:23645) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6646) 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)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
问题找到了,我自己的代码问题,我起实现ISupportFragment这个接口,Fragment生命周期方法没有去重写,只重写了你这个接口里面的方法
` mPagerAdapter = new MyPagerAdapter(mActivity.getSupportFragmentManager()); viewPager.setAdapter(mPagerAdapter); tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); tabLayout.setupWithViewPager(viewPager);
`
` public class MyPagerAdapter extends FragmentPagerAdapter {
} `
大致逻辑是这样的