gpt4 book ai didi

java - 错误 : class, 接口(interface),或预期枚举 - Android Studio

转载 作者:行者123 更新时间:2023-12-02 09:08:39 25 4
gpt4 key购买 nike

错误:需要类、接口(interface)或枚举 - Android Studio

package com.android.wowowowo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;


public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Handler h = new Handler() ;
h.postDelayed(new Runnable() {
public void run() {
startActivity(new Intent(MainActivity.this, MainActivity2.class));
}

}, 3000);
}
}
}

我想等待 3 秒并更改 Activity

最佳答案

看起来您多了一个大括号。试试这个。

package com.android.wowowowo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;


public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Handler h = new Handler() ;
h.postDelayed(new Runnable() {
public void run() {
startActivity(new Intent(MainActivity.this, MainActivity2.class));
}

}, 3000);
}
}

关于java - 错误 : class, 接口(interface),或预期枚举 - Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59584075/

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