教你实现splash欢迎页面延迟跳转的6种方法

本文介绍了六种在Android应用中实现splash启动页延迟跳转的方法,包括使用Handler.postDelayed、创建Runnable对象以及Thread.sleep等不同技术手段。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

教你实现splash页面延迟跳转的六种方法(个人总结) 

 实现方式一:
    private void initSplashPage() {
         new Handler().postDelayed(new Runnable() {
             @Override
             public void run() {
                 //跳转页面
                 Intent intent = new Intent(ShoppingCartActivity.this,spalsh.class);
                 startActivity(intent);
             }
         }, 3000);
     }


实现方式二
   
private void initSplashPage() {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                //跳转页面
                Intent intent = new Intent(ShoppingCartActivity.this, spalsh.class);
                startActivity(intent);
            }
        };
        new Handler().postDelayed(runnable, 3000);
    }


 实现页面跳转方法三
  
  private void initSplashPage() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                //睡3秒后跳转页面
                //跳转页面
                Intent intent = new Intent(ShoppingCartActivity.this, spalsh.class);
                startActivity(intent);
            }
        }).start();
    }


实现页面跳转方法四
   
private void initSplashPage() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                SystemClock.sleep(3000);
                //睡3秒后跳转页面
                //跳转页面
                Intent intent = new Intent(ShoppingCartActivity.this, spalsh.class);
                startActivity(intent);
            }
        }).start();
    }


实现页面跳转方法五
   
 private void initSplashPage() {
        new Thread(){
            @Override
            public void run() {
//                super.run();
                SystemClock.sleep(3000);
                //睡3秒后跳转页面
                //跳转页面
                Intent intent = new Intent(ShoppingCartActivity.this, spalsh.class);
                startActivity(intent);
            }
        }.start();
    }

实现页面跳转方法六
  
  private void initSplashPage() {
        new Thread(){
            @Override
            public void run() {
//                super.run();
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                //睡3秒后跳转页面
                //跳转页面
                Intent intent = new Intent(ShoppingCartActivity.this, spalsh.class);
                startActivity(intent);
            }
        }.start();
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值