第一个Android程序--Hello Android
16lz
2021-01-23
原文: http://www.anddev.org/hello_android_-_your_first_application-t31.html
编写第一个Android程序 "Hello Android"
这是什么: 这个教程演示如何创建最简单的Android程序。
能学到什么: 在Eclipse中创建一个Android工程,输入代码,创建运行配置。
难度: 0.5 of 5
最终效果:
具体步骤:
1. 首先,我们须创建一个新的工程,在Package-Explorer上空白区域右击鼠标。
2. 选择"Android Project"
3. 填写如下:
4. 这就是创建好的工程目录结构(不要惊慌,其实大多数是些资源文件)
5. 找到并打开"Hello_Android.java" 输入如下代码:
6. 打开"Open Run Dialog..." 对话框
7. 设置如下,点Apply并点击Run。
8. 模拟器启动中。。。
9. 主程序在启动。。。
10. 恭喜你,你的第一个程序运行起来了!
完整代码
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 ... { /***//**Calledwhentheactivityisfirstcreated.*/ @Override publicvoidonCreate(Bundleicicle)...{ super.onCreate(icicle); //Wewanttoviewsomeverysimpletext,soweneedaTextView TextViewtv=newTextView(this); //PutsometexttothenewlycreatedTextVIew tv.setText("HelloAndroid-by:anddev.org "+ "Thisissoooosimple=D"); //TellourApptodisplaythetextView this.setContentView(tv); } } |
更多相关文章
- 导入Android工程遇到的问题
- 代码混淆
- 常用Android应用程序中的Intent动作
- Android 再按一次退出程序三种办法
- PendingIntent实现原理和代码
- 目前最全的android恶意程序的分类谱
- Eclipse For Android 代码自动提示功能