编写第一个Android程序 "Hello Android" 这是什么: 这个教程演示如何创建最简单的Android程序。 能学到什么: 在Eclipse中创建一个Android工程,输入代码,创建运行配置。 最终效果: 具体步骤: 1. 首先,我们须创建一个新的工程,在Package-Explorer上空白区域右击鼠标。 2. 选择"Android Project" 3. 填写如下: 4. 这就是创建好的工程目录结构(不要惊慌,其实大多数是些资源文件) 5. 找到并打开"Hello_Android.java" 输入如下代码: 6. 打开"Open Run Dialog..." 对话框 7. 设置如下,点Apply并点击Run。 8. 模拟器启动中。。。 9. 主程序在启动。。。 10. 恭喜你,你的第一个程序运行起来了! 完整代码: 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); } } |
入门——第一个android程序
最新推荐文章于 2024-06-01 14:13:21 发布