ITeye博客

[ViewPager] ViewPager中FragmentStatePagerAdapter与FragmentPagerAdapter的差异

wcgdonot · 2013-12-13 09:52 · Android · 移动开发 · Markdown

Like the docs say, think about it this way. If you were to do an application like a book reader, you will not want to load all the fragments into memory at once. You would like to load and destroy Fragments as the user reads. In this case you will use FragmentStatePagerAdapter. If you are just displaying 3 "tabs" that do not contain a lot of heavy data (like Bitmaps), then FragmentPagerAdapter might suit you well. Also, keep in mind that ViewPager by default will load 3 fragments into memory. The first Adapter might destroy View hierarchy and re load it when needed, the second Adapter only saves the state of the Fragment and completely destroys it, if the user then comes back to that page, the state is retrieved.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。