Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if ((keyCode == KeyEvent.KEYCODE_BACK)) {
- if (this.isDirty()){
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(this.getString(R.string.desea_descartar_cambios))
- .setCancelable(false)
- .setPositiveButton(this.getResources().getString(R.string.si), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- AbstractDirtyActivity.this.setDirty(Boolean.FALSE);
- AbstractDirtyActivity.this.finish();
- }
- })
- .setNegativeButton(this.getResources().getString(R.string.no), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- }
Add Comment
Please, Sign In to add comment