Original article: http://www.anddev.org/hello_android_-_your_first_application-t31.html
Write the first Android program "Hello android"
What is this: this tutorial demonstrates how to create the simplest Android program.
What can be learned: Create an android project in eclipse, enter the code, and create a running configuration.
Difficulty: 0.5 of 5
Final effect:
Procedure:
1. First, create a new project and right-click the blank area on package-explorer.
2. Select "android Project"
3. Enter the following information:
4. This is the directory structure of the created Project (don't worry, most of them are resource files)
5. Locate and open "hello_android.java" and enter the following code:
6. Open the "open run dialog..." dialog box.
7. Set the settings as follows. Click Apply and then click Run.
8. The simulator is starting...
9. The main program is starting...
10. Congratulations! Your first program is running!
Complete code
Java: |
Package org. anddev. Android. hello_android;
Import Android. App. activity; Import Android. OS. Bundle; Import Android. widget. textview;
Public class hello_android extends activity ...{ /*** // ** Called when the activity is first created .*/ @ Override Public void oncreate (bundle icicle )...{ Super. oncreate (icicle ); // We want to view some very simple text, so we need a textview Textview TV = new textview (this ); // Put some text to the newly created textview TV. settext ("Hello Android-by: anddev.org" + "This is soooo simple = D "); // Tell our app to display the textview This. setcontentview (TV ); } } |