如何按时间间隔在 return 中显示一些视图,并在最后一个视图之后打开另一个活动?

How can I show some views in return with time intervals and after the last one, open another activiy?

我想制作一个启动画面并且我想显示一些视图(这已经使它们在 XML 中不可见)并且在最后一个通过 Java 代码变得可见之后,我想打开另一个 activity,我知道我应该让处理程序和可运行程序这样做,但我不知道具体怎么做! 有人可以告诉我如何使用代码吗?这是我到目前为止所做的。

public class SplashActivity extends AppCompatActivity {
private static final int SPLASH_TIME_OUT = 3600;
private static final int VIEW_COUNT = 4;
private TextView welcome_tv1, welcome_tv2, welcome_tv3;
private ImageView logo;
private Typeface typeface;
private Handler handler  = new Handler();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_splash);
    init();
    setAnimations();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            startActivity(new Intent(SplashActivity.this, MainActivity.class));
            finish();
        }
    }, SPLASH_TIME_OUT);
}

private void setAnimations() {
    YoYo.with(Techniques.FadeInDown)
            .duration(2500)
            .repeat(0)
            .playOn(logo);
    logo.setVisibility(View.VISIBLE);
    YoYo.with(Techniques.FadeInDown)
            .repeat(0)
            .delay(400)
            .duration(1000)
            .playOn(welcome_tv1);
    welcome_tv1.setVisibility(View.VISIBLE);
    YoYo.with(Techniques.FadeInDown)
            .repeat(0)
            .delay(1400)
            .duration(1000)
            .playOn(welcome_tv2);
    welcome_tv2.setVisibility(View.VISIBLE);
    YoYo.with(Techniques.FadeInDown)
            .repeat(0)
            .delay(2800)
            .duration(800)
            .playOn(welcome_tv3);
    welcome_tv3.setVisibility(View.VISIBLE);
}

private void init() {
    welcome_tv1 = findViewById(R.id.welcome_tv_one);
    welcome_tv2 = findViewById(R.id.welcome_tv_two);
    welcome_tv3 = findViewById(R.id.welcome_tv_three);
    typeface = Typeface.createFromAsset(getApplicationContext().getAssets(),
            "Fonts/myFont.ttf");
    logo = findViewById(R.id.logo);
    setTextViews();
}

private void setTextViews() {
    welcome_tv1.setText(getResources().getString(R.string.welcome_tv_txt));
    welcome_tv2.setText(getResources().getString(R.string.welcome_tv2_txt));
    welcome_tv3.setText(getResources().getString(R.string.welcome_tv3_txt));
    welcome_tv1.setTypeface(typeface);
    welcome_tv2.setTypeface(typeface);
    welcome_tv3.setTypeface(typeface);
}

如果您想创建仅 运行 用户首次启动应用程序的欢迎屏幕,您可以使用 SharedPreferences 检查它是否是第一次,显示您的欢迎视图滑块,然后最后一个打开你的 activity.

你可以看到整个实现here

希望对您有所帮助