Develop the first Android Application-helloandroid in eclipse
Step 1: Select File> New> project from the eclipse menu bar and select androidproject under android to create a new androidproject.
The new androidproject dialog box is displayed. 1. projectname (project name) 2. application name (project name by default) 3. package name (package name) 4.min SDK version (the SDK version number is the version number you selected in build target by default)
Note: when you create an Android Application in eclipse for the first time, file-> new does not have androidproject. Therefore, you can only select androidproject under file-> New-> project to create androidproject. in the new androidproject dialog box, the build target item is very narrow. It is inconvenient to select the SDK ersion. In this case, you can select Windows> newwindow In the eclipse menu item when the first androidproject is created. in a new window, You Are Going To File> New to see if an androidproject is added above the original project, in this way, you can easily select the build target (the target device) when creating the androidproject project here.
Click Finish to create a new androidproject.
Here we create the androidproject step
File-> New-> Project expand Android, select androidproject and click Next
. Project name: helloandroid
. Application name: Hello, mr. Android
. Package name: COM. example. helloandroid
Create activity: helloandroid
Min SDK version: 3
Remove the check box before use default location and select your project path.
Select the desired SDK version in build target. Select android1.5 and click fininsh.
In SRC, The helloandroid. Java source code under the com. example. helloandroid package
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Modify code
package com.example.helloAndroid;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.main); TextView tv = new TextView(this); tv.setText("hello Android nice to see you!"); setContentView(tv); }}
Run the project
Run-run select Android Application
Start Android simulator AVD
Below is the change of AVD over time
Beginning
First
Second
Third