I. What IS activity
Activity is an application component and is one of the four components. Provides an interface for users to interact with the program.
Second: How to create activity
1. The activity class that inherits Android
2. Rewrite method OnCreate ();
3. Setting the Display layout
4. Register at Activityminifast.xml
5. By default, when we create a new Android project, a mainactivity is created automatically:
6. Next, a mainactivity is registered by default in Androidmanifest.xml:
Three. Life cycle of activity
OnCreate ();--------Create, OnStart (),----------Run, onresume ()------Get focus, onPause ()-------lose Focus, onStop ()----------Pause, OnDestroy ();-----destruction, Onrestart ();-----restart
Four. Four states of activity
--Active state (active/running) activity at the top of the interface, getting focus
--Paused state (Paused) activity loses focus but is visible to the user
--Stop State (Stopped) activity is completely obscured, but retains the status and member information
--Non-operational status (killed) activity was destroyed.
Five. Multiple activity is jump through intent.
The following example is passed by clicking the button intent. Implement a jump.
Create a firstactivity and secondactivity respectively, and register the activity information in the Androidminifest.xml.
Create a factivity_main.xml and Sactivity_main.xml layout file, respectively.
The first button is a intent example that implements a parameterless return.
The second button is clicked to go to the second page and returns to carry the parameters back over. As shown in the following code
At the same time, Secondactivity.class also need to handle the button.
Run the following:
Small white Android Note "1"--android one of the four components (Activity)