这是(应该是)在 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();
}
}
)