Android组件之Fragment(三)---实战知识

本文详述了Fragment中setUserVisibleHint的废弃及其替代方法setMaxLifecycle的使用,通过源码分析展示了如何控制Fragment的生命周期。此外,对比了onHiddenChanged与setUserVisibleHint的区别,并探讨了ViewPager2的新特性,包括支持RTL和竖向滚动,以及懒加载和局部刷新的改进。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文在前面Fragment系列文章的基础上,重在想要从源码和实践运用的角度,去学习、分析、总结Fragment一些新技术函数和组件。

1.setUserVisibleHint与setMaxLifecycle

1.1 废弃原因

我们先看一下最新的setUserVisibleHint方法的注释


    /**
     * Set a hint to the system about whether this fragment's UI is currently visible
     * to the user. This hint defaults to true and is persistent across fragment instance
     * state save and restore.
     *
     * <p>An app may set this to false to indicate that the fragment's UI is
     * scrolled out of visibility or is otherwise not directly visible to the user.
     * This may be used by the system to prioritize operations s
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

itbird01

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值