安卓启动页

来源:互联网 发布:自拍比镜子丑 知乎 编辑:程序博客网 时间:2024/06/17 13:49
MainActivi.java
package com.heimizhou.app; import android.app.Activity;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.widget.ViewFlipper; /** *  * @author Kai Sun * @site http://www.heimizhou.com */public class SplashScreen extends Activity { private ViewFlipper allFlipper;private Handler handler = new Handler(){    @Override    public void handleMessage(Message msg) {    // TODO Auto-generated method stub    switch (msg.what) {    case 1:    //切换到主页面    allFlipper.setDisplayedChild(1);    break;    }    }    };    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        allFlipper = (ViewFlipper) findViewById(R.id.allFlipper);        new Handler().postDelayed(new Runnable() {@Overridepublic void run() {handler.sendEmptyMessage(1); //给UI主线程发送消息}        }, 3000); //启动等待3秒钟    }}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?><ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/allFlipper"    android:layout_width="fill_parent"    android:layout_height="fill_parent" >    <!-- 启动等待界面 -->    <RelativeLayout        android:id="@+id/splashLayout"        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:background="@drawable/splash_screen" >    </RelativeLayout>    <!-- 主界面 -->    <RelativeLayout        android:id="@+id/homeLayout"        android:layout_width="fill_parent"        android:layout_height="wrap_content" >         <TextView            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:text="@string/hello" />    </RelativeLayout> </ViewFlipper>
源:http://www.heimizhou.com/the-implementation-of-android-app-splash-screen.html

0 0
原创粉丝点击