重要檔案:

strings.xml:設定所有要呈現的文字

activity_main.xml:設定畫面的xml,是一個介面(view)

MainActivity.java:畫面所需的java檔,透過setContentView顯示特定的view

dimens.xml:整體畫面的設定,例如按鈕樣式

AndroidManifest.xml:整個應用程式設定檔

其他相關可看:https://read01.com/3RL6LG.html



strings.xml

<resources>
    <string name="app_name">HelloAndorid</string>
    <string name="title_activity_cf2">CF2</string>
</resources>


activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.iii.lcpan.helloandorid.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</RelativeLayout>


MainActivity.java

package com.iii.lcpan.helloandorid;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}


dimens.xml

<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
    <dimen name="fab_margin">16dp</dimen>
</resources>


AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.iii.lcpan.helloandorid">
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher" 應用程式圖示
        android:label="@string/app_name" 應用程式名稱
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">  (android.name)Activity所對應的類別名稱 
            <intent-filter>
                <action android:name="android.intent.action.MAIN" /> 應用程式的進入點,即開啟應用程式先執行這個Activity

                <category android:name="android.intent.category.LAUNCHER" /> 被加入LAUNCHER的應用程式列表中,應用程式安裝完畢後會自動啟動
            </intent-filter>
        </activity>
    </application>

</manifest>
arrow
arrow
    全站熱搜

    乙方 發表在 痞客邦 留言(0) 人氣()