活动和片段之间有什么区别? [英] What are the differences between activity and fragment?

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

问题描述

根据我的研究,backstack的概念及其存在方式存在显着差异:

As per my research, there is a significant difference in the concept of backstack and how they exist:

  • activity放置到activitiesbackstack时,用户 只需按back即可导航回到上一个活动 按钮.

  • 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.

Activity可以独立存在.

  • 在活动中放置fragment时,我们必须请求 fragment期间通过调用addToBackstack()保存的实例 transaction.

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

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