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

来源:互联网 发布:ai软件字体加粗 编辑:程序博客网 时间:2024/06/03 15:37

教你实现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();    }


原创粉丝点击