Android是Google主导的开放式手机平台,它的应用是基于Java语言开发的,今天下载了它的SDK,体验了一把:
首先按照官方网站上的
安装SDK文档下载了Android SDK和Eclipse插件.
然后按照官方网站上的入门文档
Hello, Android!,开始写第一个Android应用
比较有意思的是,Android的界面布局除了Java API以外,还提供了基于XML的定义,在res/layout/main.xml文件里面写上这样的内容:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Hello, Android"
- />
- </LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, Android"
/>
</LinearLayout>
然后在Java代码里面这样调用:
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- }
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main); //插件自动生成常量定义
}
就可以显示出这样的界面:
上面的界面是SDK带的模拟器界面,它有很多启动参数和设置,比如模拟不同的分辨率、网络速度,具体的内容可以参考
官方文档