package edu.hpu.init;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import edu.hpu.logic.R;
import edu.hpu.viewpager.MyViewPagerActivity;
public class StartActivity extends Activity {
//延迟1秒
private static final long delayTime = 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
// 使用Handler的postDelayed方法,3秒后执行跳转
new Handler().postDelayed(new Runnable() {
//必须加上StartActivity,否则默认是该Runable接口
public void run() {
goHome();
}
}, delayTime);
}
private void goHome() {
Intent intent = new Intent(this, MyViewPagerActivity.class);
startActivity(intent);
this.finish();
}
}
<!-- 欢迎界面 -->
<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=".StartActivity" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@drawable/logo"
android:scaleType="centerCrop" />
</RelativeLayout>