다이알로그에서 확인을 눌렀을때 액티비티를 끄게 만들수 없나요?
조회수 1208회
1 답변
-
@Override public void onBackPressed() { new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle("Closing Activity") .setMessage("Are you sure you want to close this activity?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }) .setNegativeButton("No", null) .show(); }
이런식으로 finish()메소드를 호출하면 액티비티를 종료합니다.
댓글 입력