Android APP中實現像QQ一樣的歡迎界面
現在很多app中都會有歡迎界面,可以出現自己app的推廣(也就是說廣告位置),也可以做自己的歡迎(自己app的logo)
實現上面所說的功能
簡單來說就是一個Activity跳轉到另一個Activity中,但是需要延遲3s左右
構建自己的歡迎界面,
requestWindowFeature(Window.FEATURE_NO_TITLE);隱藏標題欄
Activity中使用 setContentView(R.layout.welcome_layout)調用welcome_layout.xml
使用Handler實現異步更新
mHandler.sendEmptyMessageDelayed(msg.what, 3000);發送空Message,設置延遲3s
構建你的Index.xml
代碼塊
package com.example.testlogin;
import cn.bmob.v3.Bmob;
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 android.view.Window;
public class MainActivity extends Activity {
private static final String APPID = "999848e5d36a83ae049281de8b8ae1a5";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
mHandler.sendEmptyMessageDelayed(GO_LOGIN, 3000);
}
private static final int GO_HOME = 100;
private static final int GO_LOGIN = 200;
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
//跳進主界面
case GO_HOME:
break;
//跳進登錄界面
case GO_LOGIN:
Intent intent = new Intent(MainActivity.this,
LoginActivity.class);
startActivity(intent);
finish();
break;
}
}
};
}