@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("종료");
builder.setMessage("종료하시겠습니까?");
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if(dialog != null) {
dialog.dismiss();
}
if(which == DialogInterface.BUTTON_POSITIVE) {// 확인
finish();
}
else if(which == DialogInterface.BUTTON_NEGATIVE) {// 취소
}
}
};
builder.setPositiveButton("확인", listener);
builder.setNegativeButton("취소", listener);
builder.show();
}
return true;
}
return super.onKeyDown(keyCode, event);
}
No comments:
Post a Comment