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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…