ViewPager FragmentPagerAdapter Nullpointer

前端 未结 3 461
说谎
说谎 2020-12-08 07:04

I got this error by using the ViewPager in the Android Support package. from the Horizontal View Swiping with ViewPager Tutorial

06-19 13:07:25.950: E/Andro         


        
3条回答
  •  Happy的楠姐
    2020-12-08 07:43

    Just in case anyone doesn't read the comments of passsy's answer, here is a summary of the useful answers:

    1) Examine your getItem(int index) method very closely and look for any logic, scenarios or missing 'break' statements which might cause you to end up with a null fragment.

    2) Check that the count returned by getCount() matches the number of fragments returned in getItem(int index).

    3) Examine your imports and ensure you aren't mixing android.app.Fragment with android.support.v4.app.Fragment

提交回复
热议问题