activity

来源:互联网 发布:hexdump windows 编辑:程序博客网 时间:2024/05/16 01:01

翻译一些activity,写一些心得感受。


java.lang.Object

   ↳ android.content.Context
    ↳ android.content.ContextWrapper
    ↳android.view.ContextThemeWrapper
    ↳android.app.Activity


这里面特别要重视那个object,一直会遇到这个东西。


An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows

activity大多数情况下,是全屏幕的与用户交互的页面。


An application usually consists of multiple activities that are loosely bound to each other. Typically, one activity in an application is specified as the "main" activity, which is presented to the user when launching the application for the first time. Each activity can then start another activity in order to perform different actions. Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack (the "back stack"). When a new activity starts, it is pushed onto the back stack and takes user focus. The back stack abides to the basic "last in, first out" stack mechanism, so, when the user is done with the current activity and presses the Back button, it is popped from the stack (and destroyed) and the previous activity resumes. (The back stack is discussed more in the Tasks and Back Stack document.)

activity之间是松散地联系着的,松散在这里是褒义词,这个可以使程序的组装性增强。

由于activity的特有属性——大多数情况下全屏,所以,当第二个activity打开的时候,第一个被压入栈内。是否与栈有区别,另作讨论。

提到了关于back的编程意义上的操作,即pop出当前栈,使下面一个浮现在屏幕上。


When an activity is stopped because a new activity starts, it is notified of this change in state through the activity's lifecycle callback methods. There are several callback methods that an activity might receive, due to a change in its state—whether the system is creating it, stopping it, resuming it, or destroying it—and each callback provides you the opportunity to perform specific work that's appropriate to that state change. For instance, when stopped, your activity should release any large objects, such as network or database connections. When the activity resumes, you can reacquire the necessary resources and resume actions that were interrupted. These state transitions are all part of the activity lifecycle.

这一段讲的主要是activity的四种状态,具体详细解释无法在此段中讲述。


The rest of this document discusses the basics of how to build and use an activity, including a complete discussion of how the activity lifecycle works, so you can properly manage the transition between various activity states.


/***********************************************************************************************************************************

上面主要是对于activity高度概括性的陈述。

下面开始实践

************************************************************************************************************************************/

//以后补充状态。




0 0