一.安装sdk
1.下好sdk,貌似只有android的原始站点才能访问:http://androidappdocs.appspot.com/sdk/installing.html
根据系统选择相应的版本,我的是macos
2.在终端输入:export PATH=${PATH}:<your_sdk_dir>/tools,把android的命令加入bash路径中
二.hello,world
1.在终端输入
android create project \
--target 1 \ 选择android版本
--name helloandroid \ 程序名称
--path myandroid\ 项目路径
--activity hello\ activity的名称(类似于程序入口类)
--package com.test.hello 包名
创建了一个新的android项目
2.打开hello.java,如下:
package com.test.hello;

import android.app.Activity;
import android.os.Bundle;

public class Hello extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}


修改代码:
package com.test.hello;

import android.app.Activity;
import android.os.Bundle;

public class Hello extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv=new TextView(this);
tv.setText("Hello,World");
setContentView(tv);
}
}

也可以直接修改相应的xml文件,可以达到相同的效果,这也是推荐的方式,让activity只负责业务逻辑.
3.编译程序
我是用的ant,在终端里进入项目下,输入ant debug(会自动生成debug签名),会生成.apk文件(就是目标程序吧)
4.新建emulator
在终端输入android create avd --name new --target 1
5.启动emulator
终端输入:adb -avd new
6.安装程序到emulator
打开终端输入:adb install /path/to/your/application.apk
7.在emulator中打开此程序

更多相关文章

  1. android intent和intent action大全
  2. Android实训(一)小记
  3. Android(安卓)关闭/打开多点触控 (Android中设置不能同时点击2个v
  4. EditText实现输入限制和校验功能实例代码
  5. Android(安卓)中文api (81)——InputMethod [输入法]
  6. 解决 Android(安卓)模拟器 无法上网问题
  7. Android系列教程之七:EditText使用详解-包含很多教程上看不到的功
  8. Android事件处理分析+Android事件处理 +Android输入事件流程
  9. android api (83) —— InputMethodSession [输入法]

随机推荐

  1. Android中GPS定位的简单应用
  2. android源码下载方式
  3. Android(安卓)组件资源库
  4. Android(安卓)Porting Environment Set
  5. Android调用.NET Webservice报org.ksoap2
  6. Android(安卓)Studio bug - attribute 'a
  7. Android(安卓)Studio & ADT 快捷键配置文
  8. Ionic 运行报错No resource identifier f
  9. 从 Android(安卓)Sample ApiDemos 中学习
  10. Android开发者实用代码片段 与大家分享