屏幕转换

时间:2013-11-18 19:37:23

标签: java android

我正在尝试使用睡眠选项在两个屏幕之间创建转换,但是转换发生但是启动画面是空白的。

请遵循以下代码:

@ Override
   protected void onCreate (Bundle savedInstanceState) {
   super.onCreate (savedInstanceState);
   setContentView (R.layout.activity_screen1);
    try {
         Thread.sleep (1000);
         Initial intent = new Intent (getApplicationContext (), scren2.class);
         startActivity (initial);
        } Catch (Exception e) {
           e.printStackTrace ();
        }
    }

1 个答案:

答案 0 :(得分:1)

试试这个

protected void onCreate (Bundle savedInstanceState) {

super.onCreate (savedInstanceState);

setContentView (R.layout.activity_screen1);


    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
             Intent initial = new Intent (getApplicationContext (), scren2.class);

             startActivity (initial);

        }
    }, 1000);


}