简体   繁体   English

Android意图,片段和活动

[英]Android Intent, Fragment and Activity

I know many of you will direct me to the API. 我知道很多人会指导我使用API​​。 I am getting confused the more I read about Intent Fragment and Activity . 我越来越感到困惑,我读到的关于Intent FragmentActivity内容越多。 Can anyone please describe what are these and why are these three important for the process of android application development? 任何人都可以描述这些是什么以及为什么这三个对于Android应用程序开发过程很重要?

Thanks for you help in advance. 谢谢你的帮助提前。

1) Intent : - 1)意图: -
It's an "intention" to do an action. 这是一个行动的“意图”。 It is like sending Message to Android OS to carry Out some task. 就像向Android OS发送消息来执行一些任务一样。 For ex: Start other activity if some action happens. 例如:如果发生某些动作,请启动其他活动。 See Below Links : http://developer.android.com/reference/android/content/Intent.html 请参阅以下链接: http//developer.android.com/reference/android/content/Intent.html

2) Activity : - 2)活动: -

It is a Single Screen that users Interacts with.It is the only component that can (and must) have a user interface. 它是用户与之交互的单一屏幕。它是唯一可以(且必须)具有用户界面的组件。 Learn Activity Life cycle. 学习活动生命周期。 It is Very important. 这是非常重要的。 You Should declare your activity in manifest File. 您应该在清单文件中声明您的活动。

3) Fragment : - 3)片段: -

A Fragment is a behavior or a portion of user interface in an Activity. 片段是活动中的行为或用户界面的一部分。 We can call it like sub Part of Activity.Just Remember that Fragment May or may not have view. 我们可以把它称为活动的子部分。请记住片段可能或可能没有视图。 It is Like Small Activity,but they can be multiple on single screens and we can interact with them. 它就像小活动一样,但它们在单个屏幕上可以是多个,我们可以与它们进行交互。 Read the Fragment Doc from Developers site. 阅读开发人员网站上的Fragment Doc。 It is great place to Start. 这是开始的好地方。 see this : - http://developer.android.com/guide/components/fragments.html 看到这个: - http://developer.android.com/guide/components/fragments.html

In Simple Words, 在简单的单词中,

1) Activity: is a screen which hold view(s) for GUI components. 1)活动:是一个屏幕,用于保存GUI组件的视图。 A Window in Desktop Application. 桌面应用程序中的窗口。 It has a lifecycle like created,paused, stopped like in window. 它有一个像窗口一样创建,暂停,停止的生命周期。

2) Fragment: is a component used for dynamic GUI development. 2)片段:是用于动态GUI开发的组件。 it also has a own lifecycle. 它也有自己的生命周期。 But only difference is that it can't be used directly. 但唯一的区别是它不能直接使用。 it should be encompassed in Activity in order work. 它应该包含在活动中以便工作。 An activity may have one or more than one fragments. 活动可能包含一个或多个片段。

3) Intent: is a message passing framework from one activity to another. 3)意图:是从一个活动到另一个活动的消息传递框架。 message can be anything causing an activity to resume, passing extra to an activity or cause an application to start. 消息可以是导致活动恢复的任何内容,将额外的内容传递给活动或导致应用程序启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM