Create the first Android app helloword

Source: Internet
Author: User
1. Create an android project. In the menu, choose File> New> Android project.

2. The items displayed in the pop-up dialog box are as follows:
"Project name:". Enter the project name here;
"Build target:", select the build target of the new Android project. In this article, there are two options: "android2.1-update1" and "Google APIs ", the former indicates that the target environment is android2.1, and the latter indicates that Google map API is added to the target environment based on android2.1;

"Application name", ApplicationProgramName;
"Package name" indicates the package name of the application;
"Create activity": Create an activity and specify the Class Name of the activity. The fully qualified class name of the activity is the package name of the previous item, and the activity class name here.
"Min SDK version", the lowest SDK version. If it is set to 2.1, it is OK if it is set to 7.

3. After the project is created, the corresponding project file is generated in package explorer on the right of the workbench. The meanings of each folder are as follows:
"Src", source file directory. The package name and activity class name specified in the Wizard are shown below;
"Gen", which contains the Java source files compiled by ADT;
"Android2.1-update1", Android. jar, the build target platform of this project. android2.1 indicates that the target running environment of this project is Android SDK 2.1;
"Assets": stores the original resource files. Android does not process the files in this directory, which is different from the res directory;
"Res" is also a resource file, but the resource file ADT under this directory will generate an R. Java file after compilation, so that you can easily reference these resources in the Java source file;
"Androidmanifest. xml", andriod Application List file;
"Default. properties" is a Java property file that contains some settings of this project. By default, it contains the target platform of this project.

4. Because the activity we created here is helloworld, add the following to the corresponding helloworld. Java file:CodeYou can:
Package main. maintest;

Import Android. App. activity;
Import Android. OS. Bundle;
Import Android. widget. textview;

Public class helloworld extends activity {

@ Override
Public void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
Textview Tw = new textview (this );
Tw. settext ("Hello world! ");
Setcontentview (TW );
}
}

5. Create and configure the android Simulator
A. Choose WINDOW> Android SDK and AVD manager;
B. Select virtual devices in the left-side window;
C. Click new... in the right window;
D. Fill in or select the corresponding project and click Create AVD;
E. After the simulator is created, we can see a simulator we just created in the list;
F. Open Run-> run commands in sequence;
G. In the left-side dialog box, select the project name under Android Application;
H. Select automatic in the target tag on the right.

6. Click the run button on the toolbar or press Ctrl + F11 to start the program. After the simulator system is started, you can see "Hello World!" in our program on the screen !"

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.