Activity 界面:

welcome_layout.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/welcome_pic"    >    </LinearLayout>

Activity 代码:

package com.activity;import android.annotation.SuppressLint;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.os.Message;import com.tqg.zhenjiang.price.R;@SuppressLint("HandlerLeak")public class WelcomeActivity extends Activity  {    //延迟时间    private final static int DELAY_TIME = 1500;    //消息参数    private final static int DELAY_MSG = 1001;        @SuppressLint("HandlerLeak")    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.welcome_layout);        //延迟发送消息        mHandler.sendEmptyMessageDelayed(DELAY_MSG, DELAY_TIME);    }    private final Handler mHandler = new Handler() {        @Override        public void handleMessage(Message msg) {            switch (msg.what) {            case DELAY_MSG:                startToMainActivity();                WelcomeActivity.this.finish();                break;            default:                break;            }            super.handleMessage(msg);        }    };    //跳转主界面    private void startToMainActivity()     {        Intent intent = new Intent();        intent.setClass(this, MainActivity.class);        startActivity(intent);    }}

主要就是运用了Android Handler延迟发送消息的机制。

更多相关文章

  1. Android事件分发机制——ViewRootImpl篇(前传)
  2. Android实现界面完全全屏
  3. android计算器布局界面――基础编
  4. Android handle机制
  5. [Android][UI]模拟器启动界面动画效果的简单实现
  6. Android 8.0 跳转通知设置界面适配
  7. android binder机制及其源码解析之第二节 重要函数讲解之常用数

随机推荐

  1. android画统计图的chart engine
  2. android页面间传递对象
  3. Android电池管理
  4. Android定制出厂默认输入法
  5. Android学习
  6. Android(安卓)图片缩放与旋转
  7. android 如何在对话框中获取edittext中的
  8. This Android(安卓)SDK requires Android
  9. mapView 和textView布局
  10. 大话企业级android读书笔记(三)