有我的代码..我想在没有Thread计时器的情况下制作启动画面.. 我怎么能这样做?
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread timer = new Thread() {
public void run() {
try {
sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
// myCode();
}
}
}
};
timer.start();
} }
答案 0 :(得分:1)
您可以使用以下代码,我觉得对您有好处。
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
Intent mainIntent = new
Intent(SplashActivity.this,AnotherActivity.class);
startActivity(mainIntent);
finish();
}
},3000);
}
}