Android SDK 2.3与Eclipse最新版开发环境搭建(五)

    技术2024-07-04  64

     

    七、 第一个 Android 应用( Hello , Android World! )

    新建项目:打开Eclipse,选择 File > New > Project > Android Project,具体输入如下图:

    点击“Next”,提示如下:

    这里仅为演示,不创建测试项目。直接点击“Finish”按钮即可。

    编辑HelloAndroidWorld.java文件,内容如下:

    package org.deaboway.test;

    import android.app.Activity;

    import android.os.Bundle;

    import android.widget.TextView;

    public class HelloAndroidWorld extends Activity {

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {

    super .onCreate(savedInstanceState);

    TextView textView = new TextView(this );

    textView.setText("Hello Android World!");

    setContentView(textView);

    }

    }

    运行Android项目:点击工具栏的运行按钮,或选择菜单:Run->Run,或右键项目文件夹,会弹出“Run As”对话框,选择“Android Application”,点击“OK”按钮。

    运行效果如下,AVD加载的速度有些慢,需要耐心等待。

    同时,Eclipse的控制台也会打印出运行时的一些相关信息,如下。

    最新回复(0)