gpt4 book ai didi

java - 启动画面显示太快,然后进入下一个 Java 类

转载 作者:行者123 更新时间:2023-12-01 20:20:14 24 4
gpt4 key购买 nike

初始屏幕应该持续 3 秒,但当应用程序在 Genymotion EmulatorAndroid Studios Emulator 上运行时,它几乎完全跳过,这两个模拟器都可以完美运行其他应用程序。我不明白?

SplashScreen.java

package com.transcendencetech.juliospizzaprototype;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;

/**
* Created by Stormy Forrester on 20/03/2016.
*/
public class SplashScreen extends AppCompatActivity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash_screen);

int secondsDelayed = 4;
new Handler().postDelayed(new Runnable() {
public void run() {
startActivity(new Intent(SplashScreen.this,
SignInActivity.class));
finish();
}
}, secondsDelayed * 3);
}
}

**splash_screen,xml **

最佳答案

您应该将秒数(例如 4)乘以 1000。

因为你必须以毫秒为单位给出它。

尝试将代码更改为

 @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash_screen);

int secondsDelayed = 4;
new Handler().postDelayed(new Runnable() {
public void run() {
startActivity(new Intent(SplashScreen.this,
SignInActivity.class));
finish();
}
}, secondsDelayed * 1000);
}
}

关于java - 启动画面显示太快,然后进入下一个 Java 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44901115/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com