gpt4 book ai didi

java - "cannot be resolved to a type"是什么意思,我该如何解决? Java 安卓 4.0

转载 作者:行者123 更新时间:2023-11-29 05:39:28 25 4
gpt4 key购买 nike

这是(应该是)在 Android 4.0 中实现对话框的简单示例。这个方法 onCreateDialog() 覆盖了从 android.app.Dialog 导入的同名方法;此代码不会编译并生成下面注释中显示的错误消息。此错误消息是什么意思,我该如何解决?谢谢!

@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0:
return new AlertDialog.Builder(this)
.setIcon(R.drawable.ic_launcher)
.setTitle("This is a dialog with a stupid message...")
.setPositiveButton("Dig it",

//error message:
//DialogInterface.onClickListener cannot be resolved to a type
new DialogInterface.onClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
Toast.makeText(getBaseContext(),
"Gotcha!", Toast.LENGTH_SHORT).show();
}
}
)

最佳答案

正如错误试图告诉您的那样,没有名为 DialogInterface.onClickListener 的类型。

Java 区分大小写; you need a capital O .

关于java - "cannot be resolved to a type"是什么意思,我该如何解决? Java 安卓 4.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18154430/

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