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>


  • 相关阅读:
    Restful接口传入多参数
    map转换成JSON的3种方式
    项目打包后执行start.sh提示“no such file or directory”解决办法,linux中给文件增加权限
    如何将一个a表a1字段与b表b1字段的笛卡尔积插入到e表中
    get、set方法的取代注释之lombok插件
    推荐 33 个 IDEA 最牛配置转(Java技术栈)
    mysql-----group by 对多个字段进行分组
    mysql获取某段时间内每一天的统计数据
    发票流水号生成方式
    postman之post请求传参
  • 原文地址:https://www.cnblogs.com/Answer1215/p/3432631.html
Copyright © 2011-2022 走看看