您的位置:首页 > 其它

FragmentActivity和Activity的区别及何时使用两者

2014-04-09 09:53 375 查看
区别:A
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.


使用:use
Activity
if
you are using
android.app.Fragment
;
use
FragmentActivity
if
you are using
android.support.v4.app.Fragment
.
Never attach a
android.support.v4.app.Fragment
to
a
android.app.Activity
,
as this will cause an exception to be thrown.

http://stackoverflow.com/questions/10477997/difference-between-activity-and-fragmentactivity
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐