zoukankan      html  css  js  c++  java
  • Android FragmentPagerAdapter和FragmentStatePagerAdapter的区别

    FragmentPagerAdapter官方解释:

    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.

    意思大概就是:如果有少量的、常用的fragment,像tab标签页这样的,可以用FragmentPagerAdapter。划过的fragment,尽管视图不见了,但是会把他们保存在内存里,方便调用,因此这会占用大量的内存空间。

    FragmentStatePagerAdapter官方解释:

    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.

    意思就是说:如果有大量的fragment,或者fragment中有大量的数据(Bitmap)就用fragmentStatePagerAdater,它就像listview一样,当fragment不可见时候,仅仅保存fragment的状态,相对上面的而言,这会占用较少的内存。

  • 相关阅读:
    hdu 4963(中途相遇法)
    UVALive 6869(后缀数组)
    AC自动机小结
    poj 2409+2154+2888(Burnside定理)
    HUST 1569(Burnside定理+容斥+数位dp+矩阵快速幂)
    bunoj 34990(hash)
    CSU 1506(最小费用最大流)
    CF 514C(hash)
    lightoj 1297(三分)
    lightoj 1179(线段树)
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/4505228.html
Copyright © 2011-2022 走看看