1
0
Fork 0

PowerEditor: added confirmation for back press

This commit is contained in:
Carlos Galindo 2015-07-16 09:57:29 +02:00
commit 2f8895ff17
3 changed files with 36 additions and 2 deletions

View file

@ -1,9 +1,11 @@
package com.kauron.dungeonmanager;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ArrayAdapter;
@ -24,6 +26,28 @@ public class PowerEditor extends ActionBarActivity {
private SharedPreferences p;
private Drawable background;
@Override
public void onBackPressed() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(R.string.sure);
alert.setMessage(R.string.progress_lost);
alert.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
PowerEditor.super.onBackPressed();
}
});
alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
alert.show();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);