天天看點

android的第一個程式helloworld (有圖有真相)

1、建立工程

2、都不需要編寫代碼

非常簡單

 AndroidhelloActivity.java

package com.mrjing.org;

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

public class AndroidhelloActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
           

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

</LinearLayout>
           

strings.xml

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

    <string name="hello">Hello World, AndroidhelloActivity!</string>
    <string name="app_name">Androidhello</string>

</resources>
           

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mrjing.org"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".AndroidhelloActivity"
            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>
           
android的第一個程式helloworld (有圖有真相)
android的第一個程式helloworld (有圖有真相)
android的第一個程式helloworld (有圖有真相)
android的第一個程式helloworld (有圖有真相)
android的第一個程式helloworld (有圖有真相)
android的第一個程式helloworld (有圖有真相)
android的第一個程式helloworld (有圖有真相)
android的第一個程式helloworld (有圖有真相)
android的第一個程式helloworld (有圖有真相)
android的第一個程式helloworld (有圖有真相)

修改下面檔案:

strings.xml

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

    <string name="hello">Hello World!</string>
    <string name="app_name">Androidhello</string>

</resources>
           
android的第一個程式helloworld (有圖有真相)

繼續閱讀