android入门篇(二) 第一个Hello World系统

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










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值