Android P中不推荐使用碎片

Android P中不推荐使用碎片,第1张

概述我看着documentation并发现了这一点ThisclasswasdeprecatedinAPIlevelP.为什么在AndroidP中不推荐使用片段?解决方法:在支持库27.1.0中重写Ian’smediumpost(2018年2月28日)给我们一个解释.他是Google的AndroidFramework开发人员.LoadersinSupportLibrary 2

我看着documentation并发现了这一点

This class was deprecated in API level P.

为什么在AndroID P中不推荐使用片段?

解决方法:

在支持库27.1.0中重写

Ian’s medium post(2018年2月28日)给我们一个解释.他是Google的AndroID Framework开发人员.

Loaders in Support library 27.1.0

For Support library 27.1.0, I rewrote the internals of LoaderManager, the class powering the Loaders API and I wanted to explain the reasoning behind the changes and what to expect going forward.

Loaders and Fragments, a history
From the beginning, Loaders and Fragments were pretty tightly tIEd together at the hip. This meant that a lot of the code in FragmentActivity and Fragment were there to support Loaders, despite the fact that there are indeed fairly independent. …

What’s changed in 27.1.0
With 27.1.0, the technical debt of Loaders has been greatly reduced: …

Note: ObvIoUsly, these changes only apply to Support library Loaders. If you are using AndroID framework Loaders, please switch to the Support library Loaders as soon as possible. There are no BUG fixes or improvements planned for the framework Loader APIs.

似乎Fragment和FragmentActivity中的代码已被重构,以使Loaders成为可选的依赖项.

根据the release note,新的实施基于生命周期.

important Changes
The underlying implementation of 07002 has been rewritten to use 07003.

架构组件

在Support Library 26.1.0,Fragment和FragmentActivity采用了生命周期.

This is a special release to integrate the Support library with lifecycles from Architecture Components. If you are not using the lifecycles library, you don’t need to update from 26.0.2. For more information, see the Architecture Components release notes.

important changes

Fragment and FragmentActivity (the base class for AppCompatActivity) Now implement the lifecycleOwner interface from Architecture Components.

相比之下,AndroID P中的Fragment和Activity尚未实现lifecycleOwner接口.

在the Google+ post(ThanosFisherman’s answer中提到),伊恩发表评论:

you can’t change framework code after it has shipped – it is literally froZen in time. That means no new features and more importantly no BUG fixes. That’s not a good developer experIEnce, particularly when we do have a fully supported, up to date, backward compatible version in the Support library.

我认为这就是AndroID P不采用lifecycle的原因.因此,在AndroID P中不推荐使用Fragment.

总结

以上是内存溢出为你收集整理的Android P中不推荐使用碎片全部内容,希望文章能够帮你解决Android P中不推荐使用碎片所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1101437.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存