码迷,mamicode.com
首页 > 其他好文 > 详细

Fragment(9)FragmentActivity和Activity的区别

时间:2015-06-26 21:02:19      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

  getSupportFragmentManager()  ,FragmentActivity用在android sdk 3以下.

  getFragmentManager() + Activity 用在android sdk 3以上.

  stackoverflow的原文 

 

FragmentActivity is a subclass of Activity that was built for the Android Support Package.

The FragmentActivity class adds a couple new methods to ensure compatibility with older versions of Android, but other than that, there really isn‘t much of a difference between the two. Just make sure you change all calls to getLoaderManager() and getFragmentManager() to getSupportLoaderManager() and getSupportFragmentManager() respectively.

 

  1. Fragment is a part of an activity, which contributes its own UI to that activity. Fragment can be thought like a sub activity. Where as the complete screen with which user interacts is called as activity. An activity can contain multiple fragments.Fragments are mostly a sub part of an activity.

  2. An activity may contain 0 or multiple number of fragments based on the screen size. A fragment can be reused in multiple activities, so it acts like a reusable component in activities.

  3. A fragment can‘t exist independently. It should be always part of an activity. Where as activity can exist with out any fragment in it.

 

Fragment(9)FragmentActivity和Activity的区别

标签:

原文地址:http://www.cnblogs.com/cocl/p/4603156.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!