我正在尝试使用睡眠选项在两个屏幕之间创建转换,但是转换发生但是启动画面是空白的。
请遵循以下代码:
@ 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 ();
}
}
答案 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);
}