什么是活动和片断之间的差异 [英] What are the differences between activity and fragment
问题描述
按我的研究,有在backstack的概念的显著差异,以及他们如何存在:
As per my research, there is a significant difference in the concept of backstack and how they exist:
-
在一个
活动
被放置到backstack
的活动
用户 可以导航回到previous活动,只需pressing的返回
按钮。
When an
activity
is placed to thebackstack
ofactivities
the user can navigate back to the previous activity by just pressing theback
button.
活动
可以独立存在。
-
在一个
片段
被放置到活动中,我们必须要求 例如保存调用addToBackstack()
的片段在
交易
。
When an
fragment
is placed to the activity we have to request the instance to be saved by callingaddToBackstack()
during thefragment
transaction
.
片段
都有生存的活动里面
是否有任何额外的差异?
Are there any additional differences ?
推荐答案
这是两个完全不同的事情:
Those are two completely different things:
这是活动是一个应用程序组件,它提供了一个屏幕,通过它,用户可以为了做一些互动。更多细节: http://developer.android.com/guide/components/activities.html
An Activity is an application component that provides a screen, with which users can interact in order to do something. More details: http://developer.android.com/guide/components/activities.html
而一个片段重新presents行为或用户界面中的活动的一部分。 http://developer.android.com/guide/components/fragments.html
Whereas a Fragment represents a behavior or a portion of user interface in an Activity. http://developer.android.com/guide/components/fragments.html
这篇关于什么是活动和片断之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!