Fragment ||| support.Fragment

Which One should I use?

Why ?

//Best Answers from StackOverflow,

THE DEF

  • android.support.v4.app.Fragment is the Fragment class in the android support library, which is a compatibility package that allows you to use some of the newer features of Android on older versions of Android, android.app.Fragment is the Fragment class in the native version of the Android SDK. It was introduced in Android 3 (API 11).
  • If you want to make your app use fragments, and want to target devices before API 11, you must use android.support.v4.app.Fragment. However, if you're only targeting devices running API 11 or above, you can use android.app.Fragment.
-----------WHICH ONE SHOULD I USE ----------------------------


  • 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.
  •  big reason to stick with the SupportFragment for a while is that you do not have access to the ChildFragmentManager until API 17. The support library will give you a support version of the child fragment manager.This becomes a big deal if you have fragments that contain other fragments. This is common in tablet applications with a good deal of complexity and/or your overall architecture is based on either a tabbed layout or uses the navigation drawer.
  • I was also getting frustrated at having to include the support libraries, despite targeting Android 4.0+ - but it seems it is officially recommended




#Android

要查看或添加评论,请登录

社区洞察

其他会员也浏览了