Google Android之使用XML布局

package org.andylee1988;

import android.app.Activity;

import android.os.Bundle;

public class HelloAndylee1988 extends Activity {

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super .onCreate(savedInstanceState);

        setContentView(R.layout. main );

    }

}

 

Google Android之使用XML布局

 

编辑main.xml,输入以下代码:

<? xml version = "1.0" encoding = "utf-8" ?>

< TextView xmlns:android = "http://schemas.android.com/apk/res/android"

android:layout_width = "fill_parent"

android:layout_height = "fill_parent"

android:text = "@string/hello" />

 

 

Google Android之使用XML布局

 

编辑strings.xml,输入:

<? xml version = "1.0" encoding = "utf-8" ?>

< resources >

    < string name = "hello" > Hello, andylee1988! I am a string resource! </ string >

    < string name = "app_name" > Andylee1988 </ string >

</ resources >

Google Android之使用XML布局

 

运行后将看到:

 

Google Android之使用XML布局