新手学习,请轻喷! 好多东西都不规范,请指导!
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
/**
*
* @Description 应用起始页
* @author wesley
* @date 2015年1月23日 上午11:55:08
*
*/
public class WelcomeActivity extends Activity {
//延迟3秒
private static final long SPLASH_DELAY_MILLIS = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
new Handler().postDelayed(new Runnable() {
public void run() {
Home();
}
}, SPLASH_DELAY_MILLIS);
}
/**
* 进入主页
*/
private void Home(){
Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
WelcomeActivity.this.startActivity(intent);
WelcomeActivity.this.finish();
}
}
配置文件:activity_welcome.xml
<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="${relativePackage}.${activityClass}" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/welcome"
android:scaleType="fitCenter"
android:contentDescription="@string/welcome"/>
</RelativeLayout>