什么是活动和片断之间的差异 [英] What are the differences between activity and fragment

查看:220
本文介绍了什么是活动和片断之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按我的研究,有在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 the backstack of activities the user can navigate back to the previous activity by just pressing the back button.

活动可以独立存在。

  • 在一个片段被放置到活动中,我们必须要求 例如保存调用 addToBackstack()片段在 交易

  • When an fragment is placed to the activity we have to request the instance to be saved by calling addToBackstack() during the fragment 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆