Android学习笔记(5)——Android——HelloWorldDemo

工程目录结构:


    HelloWorldActivity.java程序清单

package com.oristand;

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

public class HelloWorldActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);//到layout目录下会对应一个main.xml配置文件,改文件决定了你要使用的那些组件,以及组件的属性,比如TextView、EditText、Button等
    }
}

 

    main.xml程序清单

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/hello_world" android:layout_width="fill_parent"
	android:layout_height="fill_parent" android:gravity="center_vertical|center_horizontal"
	android:text="@string/hello_world" />

 

   R.java程序清单 —— res目录下的任何一个配置修改后,该文件会自动修改,这就是mvc模式的好处,一旦model修改,view也相应的改变,这就是mvc的优势

package com.oristand;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
    }
    public static final class id {
        public static final int hello_world=0x7f050000;
    }
    public static final class layout {
        public static final int main=0x7f030000;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int hello_world=0x7f040000;
    }
}

  

   string.xml程序清单

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello_world">Hello World!</string>
    <string name="app_name">HelloWorldDemo</string>
</resources>

 
   AndroidManifest.xml程序清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.oristand"
      android:versionCode="1"
      android:versionName="1.0.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".HelloWorldActivity"
                  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>
</manifest> 

   

 运行配置

 

运行结果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值