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的状态,相对上面的而言,这会占用较少的内存。

  • 相关阅读:
    MySQL和hive对比表结构脚本
    服务器端口3次不通报警
    CentOS 7 安装以及配置桌面环境
    MySQL修改参数不重启生效
    linux mysql 5.7.17 编译安装小记
    react脚手架应用以及iview安装
    weex具体安装教程
    npm教程2——脚手架原理及jQuery和bootstrap引入
    npm具体安装教程
    JAVA学习总结(六)
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/4505228.html
Copyright © 2011-2022 走看看