如何设置启动画面的时间限制? [英] How do I set a time limit to my splash screen?

查看:109
本文介绍了如何设置启动画面的时间限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中为Android应用编码。我开发了一个启动屏幕,我需要在我的应用程序启动之前显示5秒钟。如何做?

解决方案

 线程计时器=新Thread()
{
public void run(){
try {
sleep(2000);
} catch(InterruptedException e){
// TODO自动生成的catch块
e.printStackTrace();
}
finally
{
Intent i = new Intent(SplashScreen.this,MainActivity.class);
finish();
startActivity(i);
}
}
};
timer.start();


I am coding in Eclipse for an Android App. I have developed a splash screen which I need to display for 5 seconds before my app starts. How to do it?

解决方案

       Thread timer=new Thread()
        {
            public void run() {
                try {
                    sleep(2000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                finally
                {
                    Intent i=new Intent(SplashScreen.this,MainActivity.class);
                    finish();
                    startActivity(i);
                }
            }
        };
        timer.start();

这篇关于如何设置启动画面的时间限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆