gpt4 book ai didi

java - 找不到符号类 MakeText 错误

转载 作者:搜寻专家 更新时间:2023-11-01 08:25:59 28 4
gpt4 key购买 nike

这是我实现 Toast 的方式:

    if ((name == "") || (pass == "")){
Toast invalidLoginToast = new Toast.makeText(this, "aaa", 3).show();
} else {
Intent intent = new Intent (this, AnnouncementsActivity.class);
String deviceId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
intent.putExtra("NAME", name);
intent.putExtra("ID", deviceId);
startActivity(intent);
}

但是我得到了错误

Error:(34, 48) error: cannot find symbol class makeText

必要的导入已经完成。我是否向方法中发送了错误的参数?

最佳答案

Instantiate a Toast object with one of the makeText() methods. This method takes three parameters: the application Context, the text message, and the duration for the toast. It returns a properly initialized Toast object. You can display the toast notification with show();

Toast.makeText(context, text, duration)

阅读有关的官方指南Toast

  Toast.makeText(CurrentActivityName.this,"aaa",Toast.LENGTH_SHORT).show();

关于java - 找不到符号类 MakeText 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45073423/

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