Android hello world例項

banq發表於2011-11-22
Android hello world example 展示了開發Android幾個過程:

開發環境需要:JDK 1.6
Eclipse IDE 3.7 , Indigo
Android SDK

1.安裝Install Android SDK

http://developer.android.com/sdk/index.html

2.安裝Install ADT Eclipse plugin
在Eclipse的Help->Install New Software,輸入https://dl-ssl.google.com/android/eclipse/

3.建立Create an Android Virtual Device (AVD)
在Eclipse工具條選擇Android Virtual Device (AVD),點按new建立一個AVD。

4.建立Create Android Project with Eclipse (Wizard)
在Eclipse中File -> New -> Project….”, “Android Project“

5.編碼Code it…
HelloWorldActivity.java

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
 
public class HelloWorldActivity extends Activity {
    /** Called when the activity is first created. */
    @[author]Override[/author]
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        TextView text = new TextView(this);
        text.setText("Hello World, Android - mkyong.com");
        setContentView(text);
    }
}
<p class="indent">

6.執行Start it in Android Virtual Device (AVD)

案例原始碼下載:

http://www.mkyong.com/wp-content/uploads/2011/11/Android-HelloWorld.zip

相關文章