Android New project manually add layout layouts

Source: Internet
Author: User

Preface : This is the first chapter of the first line of code learned, before using Eclipse to create an Android project is automatically generated in the Mainactivity.java file and the layout folder under the Activity_main.xml layout file, today the automatic generation of these files are removed, manually created these two files, so write down the essay to record the deepening impression, and this is the first time since the application blog published something, is to take notes as a habit to keep under Go, OK, here it is ....

1. All the steps to create the project are the same, only until the last tick of the Create Activity is removed, then click Finish

    

2. After the project has been created to see what the file, we see the src and Layout folder is not a file, then we will proceed to create the file

      

3. First, we create the package com.example.helloworld2under the src folder, create the package, create the Mainactivity.java class in the package, and under the Layout folder , create the first_layout.xml , as follows:

      

4. Write down the following code in the Mainactivity.java file, first, the class inherits from the activity class and then implements the OnCreate () method, which is called by the system when the activity is created. Is the beginning of an activity life cycle)

      

    

5. Add an activity to the Androidmanifest.xml with the following code:

      

6. Finally, just add a line of code to load the layout just OK

      

7. Finally, run as is running.

      

Android New project manually add layout layouts

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.