Tuesday, July 11, 2017

Android FragmentPagerAdapter vs FragmentStatePagerAdapter

FragmentPagerAdapter - 페이지 갯수가 고정적일때
About FragmentPagerAdapter Google's guide says:
This version of the pager is more useful when there are a large number of pages, working more like a list view. When pages are not visible to the user, their entire fragment may be destroyed, only keeping the saved state of that fragment. This allows the pager to hold on to much less memory associated with each visited page as compared to FragmentPagerAdapter at the cost of potentially more overhead when switching between pages.

FragmentStatePagerAdapter - 페이지 갯수가 가변적일때
And about FragmentStatePagerAdapter:
This version of the pager is best for use when there are a handful of typically more static fragments to be paged through, such as a set of tabs. The fragment of each page the user visits will be kept in memory, though its view hierarchy may be destroyed when not visible. This can result in using a significant amount of memory since fragment instances can hold on to an arbitrary amount of state. For larger sets of pages, consider FragmentStatePagerAdapter.

No comments:

Post a Comment