`
lixinye0123
  • 浏览: 324284 次
  • 性别: Icon_minigender_1
  • 来自: 温州
社区版块
存档分类
最新评论

第一个Android程序--Hello Android

阅读更多

原文: http://www.anddev.org/hello_android_-_your_first_application-t31.html

编写第一个Android程序 "Hello Android" 

这是什么: 这个教程演示如何创建最简单的Android程序。
能学到什么: 在Eclipse中创建一个Android工程,输入代码,创建运行配置。

难度: 0.5 of 5 Wink

最终效果:



具体步骤:
1. 首先,我们须创建一个新的工程,在Package-Explorer上空白区域右击鼠标。



2. 选择"Android Project"



3. 填写如下:



4. 这就是创建好的工程目录结构(不要惊慌,其实大多数是些资源文件)



5. 找到并打开"Hello_Android.java" 输入如下代码:




6. 打开"Open Run Dialog..." 对话框



7. 设置如下,点Apply并点击Run。



8. 模拟器启动中。。。



9. 主程序在启动。。。



10. 恭喜你,你的第一个程序运行起来了!




完整代码
Rolling Eyes

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); 
    }
 
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics