Activity (1), Activity (

Source: Internet
Author: User

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.