看源码,主要区别是它们的destroyItem方法,FragmentPagerAdapter中的是调用了detach方法,只是从UI中分离出来,fragment仍在内存中。FragmentStatePagerAdapter则是调用的remove方法,这个会将Fragment移除销毁,减少内存的占用。
所以Adapter的count不多的时候,使用FragmentPagerAdapter更为合适;count过多的时候不宜使用FragmentStatePagerAdapter,会占用过多内存。(当然也要根据具体需求而定)


网友评论