作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是(应该是)在 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/
我是一名优秀的程序员,十分优秀!