Android Activity

来源:互联网 发布:淘宝充气娃娃真人演示 编辑:程序博客网 时间:2024/05/22 09:02

First of all, what is an activity?
Let me paint you a picture, suppose that you are a director, and you are directing a play.
Now, you need to design all the scenes that you want to show to your audiences.
Here are go, remember that every scene is an Activity.
*******************************************************************
So, an Activity is a picture that you want to show in the monitor, and you use it to make interaction with your users.
*******************************************************************
And then, you should arrange your stage properties.
You can decide which actor(actress) should be appear in you scene, and how many actors(actresses) you need. When you find a actor(actress),
you should tell him(her) what does he(she) should do in the stage, and you can decide where to put them in the stage.
Ok, let's make a conclusion:
*******************************************************************
You are a director.
An application(a software) is a play, is a show, it contains many scenes to show to your audiences.
An activity is a single scene, in Java language, it is a Class which must extend from the super class named Activity.
An UI widget is a actor(actress), it's performance is manipulated by you.
*******************************************************************

 

Now, let's begin to direct your play.
*******************************************************************
Step1: You need a manifest to list all your actors(actresses).
In java language they are classes, for instance, Activities, Intents, Services, Content Providers.
*******************************************************************

 

In Android, the manifest is named as AndroidManifest.xml, here is a manifest.

 

Step2: You need to select actors(actresses) to arrange your scene.
In Android, you arrange your widgets for one Activity in a XML file in a folder named 'layout'.
Here is a layout, main.xml.
By the way, you can use "DroidDraw" to design your layout.
You can download it at http://www.droiddraw.org/

 

Step3: Design the lines that you want your widgets to show in the stage.

 

Step4: Tell your actors what to do in the stage. Namely, you should design the activity here.

原创粉丝点击