其实我的问题是当我按下后退按钮时,它显示dialog
,并且同时应用程序完成而没有对键进行任何操作?任何人能解决这个问题吗?onBackpressed中的问题()
@Override
public void onBackPressed() {
super.onBackPressed();
AlertDialog.Builder ab = new AlertDialog.Builder(this);
ab.setMessage("Really want to exit");
ab.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
ab.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Main.super.onBackPressed();
}
});
ab.create();
ab.show();
}
如果我按也没有应用封闭如何限制该活动,如果我不按任何 –
@ A.asha检查我更新的答案。删除这个** Main.super.onBackPressed(); ** –