0
我有这样的方法:如何从另一个类调用super()?
@Override
public void onBackPressed() {
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setCancelable(false);
alertDialog.setTitle("Sair");
alertDialog.setMessage("Do you wanna leave?");
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
super.onBackPressed();
}
});
alertDialog.show();
}
这种方法使我有以下错误:
The method onBackPressed() is undefined for the type Object.
我怎么能称之为超级方法?
它适用于超级。 – CaptRisky