Sunday, February 20, 2011

Android Study Notes 1 - "Hello World"

"Hello World"

strings.xml

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

<resources>

<string name="hello">Hello World, DroidActivity!</string>

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

<string name="hello1">你好!</string>

</resources>

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="@string/hello"

/>

<TextView android:id="@+id/textView1"android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="@string/hello1"></TextView>

</LinearLayout>

DroidAvtivity.java

package com.myandroid.droid1;
import android.app.Activity;
import android.os.Bundle;
public class DroidActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

No comments: