zoukankan      html  css  js  c++  java
  • 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>


  • 相关阅读:
    bootmgr is missing
    【转】ahci和IDE的区别
    win10系统故障代码:0xc000014c
    c++小数点后舍入
    关于类里再声明自身类实例的思考
    Java集合
    Python图片转字符画
    102. Binary Tree Level Order Traversal
    1041. Robot Bounded In Circle
    144. Binary Tree Preorder Traversal
  • 原文地址:https://www.cnblogs.com/Answer1215/p/3432631.html
Copyright © 2011-2022 走看看