PowerEditor: added confirmation for back press
This commit is contained in:
parent
63ae84f1f5
commit
2f8895ff17
3 changed files with 36 additions and 2 deletions
|
@ -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);
|
||||
|
|
Reference in a new issue