下面的代码不会编译。我知道在进行覆盖时,替换类必须与原始类的签名完全匹配,但我认为我正在仔细遵循 Android 文档中的示例。
错误信息:
overrides android.app.Activity.onCreateDialog
The return type is incompatible with Activity.onCreateDialog(int)
onCreateDialog()
方法:
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(R.drawable.ic_launcher)
.setTitle("This is a dialog with a stupid message...")
//more code here setting additional properties
);
return builder.create();
}
}