安卓程序怎么设置启动界面?
发布网友
发布时间:2022-05-02 03:58
我来回答
共2个回答
热心网友
时间:2022-06-27 23:51
代码如下
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final long start = System.currentTimeMillis();
new Thread(){
public void run() {
long time = System.currentTimeMillis()-start;
if(time<2000){
SystemClock.sleep(2000-time);
Intent intent = new Intent(SplashActivity .this,MainActivity.class);
startActivity(intent);
}
};
}.start();
}
}
热心网友
时间:2022-06-27 23:51
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(SplashActivity.this, MainActivity.class));
SplashActivity.this.finish();
}
}, 1000);
可以这样,求采纳