片段还是支持片段?

编程入门 行业动态 更新时间:2024-10-23 01:55:21
本文介绍了片段还是支持片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个支持 Android >= 4.0 的应用程序.它使用 android.app 包中的片段.因为我在 4.0 中遇到了旧片段实现的问题,比如 这个,那个已在支持库中修复,我正在考虑从支持库切换回片段实现以获得更可靠和一致的实现.

I am developing an app that supports Android >= 4.0. It uses fragments from the android.app package. As I am facing problems with the older fragment implementation in 4.0, like this one, that are already fixed in the support library, I am considering switching back to the fragment implementation from the support library to get a more reliable and consistent implementation.

您对此有何看法?在针对 Android 4 进行开发时,您是否使用支持库中的片段(即使它们已经可用)?

What is your opinion on this? Are you using fragments from the support library, even though they are already available, when developing for Android 4?

推荐答案

根据我的经验,在所有 Android 设备上使用相同的片段实现是一个很大的优势.当使用本机片段在 Android 4.0 上保存状态时,我无法摆脱所有 NullPointerExceptions,支持库它们都消失了.此外,到目前为止,我看不出这种方法有任何缺点.

From my experience, using the same fragment implementation on all Android devices is a great advantage. I could not get rid of all NullPointerExceptions when state is saved on Android 4.0 using native fragments, with the support library they are all gone. Also I could not see any disadvantage so far with this approach.

所以我现在对自己的问题的回答是:在为 Android 4.x 开发时,使用支持库中的片段是个好主意.支持库修复了旧片段实现中仍然存在的错误,并且经常更新以修复更多错误.

So my answer to my own question is now: When developing for Android 4.x, using the fragments from the support library is a good idea. The support library has bugs fixed that are still present in older fragment implementations and is frequently updated with more bug fixes.

更多推荐

片段还是支持片段?

本文发布于:2023-10-16 05:38:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1496654.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:片段

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!