Android 引导页开发管理2

来源:互联网 发布:淘宝高仿衣服怎么搜 编辑:程序博客网 时间:2024/06/11 19:44

《Android 引导页开发管理1》说明的是连续页面的闪烁效果,本次文章显示的是,一张效果效果图等待3s后进入主页面。

后续开发可以显示一段flash或者其他效果图看看。

1.splash.xml布局文件

 1 2 3 4 5 6 7 8 910111213
<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"    tools:context=".SplashActivity" >    <ImageView        android:layout_width="match_parent"        android:layout_height="match_parent"        android:background="@drawable/welcome_android"        android:scaleType="fitCenter" /></RelativeLayout>

2.SplashActivity类,使用Handler的postDelayed方法,3秒后执行跳转到主视图

 1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637383940414243
package cn.eoe.leigo.splash;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;/** *  * @{#} SplashActivity.java Create on 2013-5-2 下午9:10:01     *     * class desc:   启动画面 * * <p>Copyright: Copyright(c) 2013 </p>  * @Version 1.0 * @Author <a href="mailto:gaolei_xj@163.com">Leo</a>    *   * */public class SplashActivity extends Activity {    //延迟3秒     private static final long SPLASH_DELAY_MILLIS = 3000;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.splash);        // 使用Handler的postDelayed方法,3秒后执行跳转到MainActivity         new Handler().postDelayed(new Runnable() {            public void run() {                goHome();            }        }, SPLASH_DELAY_MILLIS);    }    private void goHome() {        Intent intent = new Intent(SplashActivity.this, MainActivity.class);        SplashActivity.this.startActivity(intent);        SplashActivity.this.finish();    }}

3.配置AndroidManifest.xml

 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="cn.eoe.leigo.splash"    android:versionCode="1"    android:versionName="1.0" >    <uses-sdk        android:minSdkVersion="10"        android:targetSdkVersion="10" />    <application        android:icon="@drawable/logo"        android:label="@string/app_name" >        <activity            android:name=".SplashActivity"            android:configChanges="keyboardHidden"            android:label="@string/app_name"            android:launchMode="singleTask"            android:screenOrientation="portrait"            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>        <activity android:name=".MainActivity" />    </application></manifest>

声明:eoe文章著作权属于作者,受法律保护,转载时请务必以超链接形式附带如下信息

原文作者: gaolei_xj

原文地址: http://my.eoe.cn/leigo/archive/3264.html









0 0