我正在开发一个支持 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.
更多推荐
片段还是支持片段?
发布评论