您的位置:首页 > 移动开发 > Android开发

实现启动界面SplashActivity

2015-12-12 22:26 381 查看
public class SplashActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_layout);

new Handler().postDelayed(new Runnable() {
public void run() {
/* Create an Intent that will start the LoginActivity. */
Intent mainIntent = new Intent(SplashActivity.this,
LoginActivity.class);
SplashActivity.this.startActivity(mainIntent);
SplashActivity.this.finish();
}
}, 2000);
}
}

大致原理就是在当前Activity 的Layout 中加载一张要显示图片作为背景,然后创建一个延迟启动的线程,延迟的时间是2000ms。在这个线程中创建启动第一个Activity的方法

代码是从别人那里抄来的,Handler()的具体细节以后研究。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android开发