Activity (1), Activity (
An application contains at least one Activity. The Activity startup process is as follows: when an application is started, the android operating system will access the AndroidManifest of the application. xml file (this file describes the components used by the application, and the Activity component is in AndroidManifest. (registered in the xml file), determines which Activity to start, such as starting the default Activity → MainActivity, is the entry of the application. First, generate the MainActivity object and call the onCreate () method of the object to read the layout file activity_main.xml (this file is used to control the display content of the Activity)
Relationship between Activity and layout file activity_main.xml
Activity_main.xml is located in the res folder and the content is as follows:
All files in the res folder are generated in R. java in the gen folder.
SetContentView of the onCreate () method of MainActivity reads the ID of the layout file, which is used to show MainActivity the content defined in the layout file corresponding to this ID
Get the object representing the control in Activity:
The content displayed in the Activity depends on the layout file. After you declare a control using an xml tag in the layout file, the content remains unchanged after the content is written. The content cannot be changed after the user interacts with the program, you can use java code to obtain the Objects representing the control, and control the display content of the control by modifying the properties of the object or calling the method of the object.