5. How to set up a Activity

1. Create a new xml in "layout" folder "splah.xml"

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

</LinearLayout>

 

2. Create a java file called "Splash.java"

package com.example.thenewboston;

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

public class Splash extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.splash);
    }

    
}

3. MainFest.xml

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.thenewboston.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.thenewboston.Splash">
            <intent-filter>
                <action android:name="com.example.thenewboston.MAINACTIVITY" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

</manifest>
其中添加了       
   <activity android:name="com.example.thenewboston.Splash"> // Class name <intent-filter> <action android:name="com.example.thenewboston.MAINACTIVITY" /> //Start point> Class name with all catpial latter <category android:name="android.intent.category.DEFAULT" /> // change LAUNCHER to DEFAULT </intent-filter> </activity>


posted @ 2013-11-20 05:54  Zhentiw  阅读(205)  评论(0编辑  收藏  举报