1,开打adt-bundle-windows/eclipse/eclipse.exe
2,启动虚拟机
如果没有点击new 新建一个
启动的时候,建议搞一个7,尺寸刚刚好
经过一个漫长的等待,终于出来了
右键新建一个android系统
一直next
点击Finish创建成功。
3, 右键工程新建一个Class HelloWorldActivity
4, 新建一个layout的xml文件
右键layout, New -> Other -> Android -> Andtoid XML Layout File
在values/strings.xml中添加一句字符串
<resources>
<string name="app_name">demo1</string>
<string name="hello_world">Hello world !!!!</string>
</resources>
在hello.xml中添加一个TextView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" <!-- 这里就代表,显示strings.xml的hello_world字符串 -->
/>
</LinearLayout>
5,布局文件关联Activity类
package com.ts.activity;
import com.ts.demo1.R;
import android.app.Activity;
import android.os.Bundle;
public class HelloActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 将layout的中hello布局文件,关联到当前的Activity
setContentView(R.layout.hello);
}
}
6,修改AndroidManifest.xml
在application节点下,声明activity
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- 声明一个activity, 并且设置为入口主程序 -->
<activity
android:name="com.ts.activity.HelloActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
注:以上intent-filter代表该activity为程序入口
7,运行demo