活动和片段之间有什么区别? [英] 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:
-
将
activity
放置到activities
的backstack
时,用户 只需按back
即可导航回到上一个活动 按钮.
When an
activity
is placed to thebackstack
ofactivities
the user can navigate back to the previous activity by just pressing theback
button.
Activity
可以独立存在.
-
在活动中放置
fragment
时,我们必须请求fragment
期间通过调用addToBackstack()
保存的实例transaction
.
When an
fragment
is placed to the activity we have to request the instance to be saved by callingaddToBackstack()
during thefragment
transaction
.
Fragment
必须住在activity
还有其他区别吗?
推荐答案
这是两个完全不同的东西:
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
其中片段表示活动中的行为或用户界面的一部分. 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屋!