Dialog: confirmation when dismissed
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Topic: I want to be able to cancel a dismiss call on a dialog.
I am entering information thorugh a dialog. When data inside the dialog has changed and the user dismisses the dialog without saving (by pressing back or clicking outside of the dialog), I want to be able to prevent that dismis by showing a confirmation dialog, that asks the user if he really wants do dismiss the dialog.
An analagy for what I am looking for is in VBA, where the cancel-variable of a beforeSave-listener can be set to "true", so that the file is not saved, even though save is pressed.
I could not find a solution that I can place inside the dismissListener of the dialog.
Thanks a lot in advance and best regards!
android dialog listener
add a comment |
Topic: I want to be able to cancel a dismiss call on a dialog.
I am entering information thorugh a dialog. When data inside the dialog has changed and the user dismisses the dialog without saving (by pressing back or clicking outside of the dialog), I want to be able to prevent that dismis by showing a confirmation dialog, that asks the user if he really wants do dismiss the dialog.
An analagy for what I am looking for is in VBA, where the cancel-variable of a beforeSave-listener can be set to "true", so that the file is not saved, even though save is pressed.
I could not find a solution that I can place inside the dismissListener of the dialog.
Thanks a lot in advance and best regards!
android dialog listener
add a comment |
Topic: I want to be able to cancel a dismiss call on a dialog.
I am entering information thorugh a dialog. When data inside the dialog has changed and the user dismisses the dialog without saving (by pressing back or clicking outside of the dialog), I want to be able to prevent that dismis by showing a confirmation dialog, that asks the user if he really wants do dismiss the dialog.
An analagy for what I am looking for is in VBA, where the cancel-variable of a beforeSave-listener can be set to "true", so that the file is not saved, even though save is pressed.
I could not find a solution that I can place inside the dismissListener of the dialog.
Thanks a lot in advance and best regards!
android dialog listener
Topic: I want to be able to cancel a dismiss call on a dialog.
I am entering information thorugh a dialog. When data inside the dialog has changed and the user dismisses the dialog without saving (by pressing back or clicking outside of the dialog), I want to be able to prevent that dismis by showing a confirmation dialog, that asks the user if he really wants do dismiss the dialog.
An analagy for what I am looking for is in VBA, where the cancel-variable of a beforeSave-listener can be set to "true", so that the file is not saved, even though save is pressed.
I could not find a solution that I can place inside the dismissListener of the dialog.
Thanks a lot in advance and best regards!
android dialog listener
android dialog listener
asked Nov 25 '18 at 9:16
earthlingearthling
6519
6519
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can maintain the state of dialog open/ close in a boolean and handle it. When you open the dialog you make it true and when user clicks back or outside the dialog check that boolean and show the alert pop-up and when dialog closes (dismisses) make boolean to false.
Hello Raj, I am not quite sure how this will work. Do you mean that I should reopen the dialog, when the boolean is a certain value?
– earthling
Nov 25 '18 at 11:26
Can you explain me how the content inside dialog you will be changing and saving in normal case? You will be placing edit text and button in dialog?
– Raj
Nov 25 '18 at 11:39
Hello Raj, exactly. I have a list view, and I open the individual elements of that list view with a dialog. The information of that item can be changed with the dialog.
– earthling
Nov 25 '18 at 12:16
alert.setCancelable(false); // where alert is instance of AlertDialog.Builder - you can use this to disable dialog close when clicking outside the dialog. As already mentioned in order to handle back press you must maintain a boolean when dialog open and close so that when back pressed onBackPressed() override method will be called where you can check boolean show a toast message if you need.
– Raj
Nov 25 '18 at 12:37
Ok, now I got it. Is there a way to do something similar, when a click occurs outside of the dialog?
– earthling
Nov 25 '18 at 13:35
|
show 1 more comment
user these methods on your dialog view to prevent cancel dialog
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.show();
Thank you for your reply. However, this is not what I am looking for. I want to be able to dismiss the dialog when clicking outside of the dialog, when no infarmation hast changed, so disabling it overall is not an option.
– earthling
Nov 25 '18 at 11:08
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466124%2fdialog-confirmation-when-dismissed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can maintain the state of dialog open/ close in a boolean and handle it. When you open the dialog you make it true and when user clicks back or outside the dialog check that boolean and show the alert pop-up and when dialog closes (dismisses) make boolean to false.
Hello Raj, I am not quite sure how this will work. Do you mean that I should reopen the dialog, when the boolean is a certain value?
– earthling
Nov 25 '18 at 11:26
Can you explain me how the content inside dialog you will be changing and saving in normal case? You will be placing edit text and button in dialog?
– Raj
Nov 25 '18 at 11:39
Hello Raj, exactly. I have a list view, and I open the individual elements of that list view with a dialog. The information of that item can be changed with the dialog.
– earthling
Nov 25 '18 at 12:16
alert.setCancelable(false); // where alert is instance of AlertDialog.Builder - you can use this to disable dialog close when clicking outside the dialog. As already mentioned in order to handle back press you must maintain a boolean when dialog open and close so that when back pressed onBackPressed() override method will be called where you can check boolean show a toast message if you need.
– Raj
Nov 25 '18 at 12:37
Ok, now I got it. Is there a way to do something similar, when a click occurs outside of the dialog?
– earthling
Nov 25 '18 at 13:35
|
show 1 more comment
You can maintain the state of dialog open/ close in a boolean and handle it. When you open the dialog you make it true and when user clicks back or outside the dialog check that boolean and show the alert pop-up and when dialog closes (dismisses) make boolean to false.
Hello Raj, I am not quite sure how this will work. Do you mean that I should reopen the dialog, when the boolean is a certain value?
– earthling
Nov 25 '18 at 11:26
Can you explain me how the content inside dialog you will be changing and saving in normal case? You will be placing edit text and button in dialog?
– Raj
Nov 25 '18 at 11:39
Hello Raj, exactly. I have a list view, and I open the individual elements of that list view with a dialog. The information of that item can be changed with the dialog.
– earthling
Nov 25 '18 at 12:16
alert.setCancelable(false); // where alert is instance of AlertDialog.Builder - you can use this to disable dialog close when clicking outside the dialog. As already mentioned in order to handle back press you must maintain a boolean when dialog open and close so that when back pressed onBackPressed() override method will be called where you can check boolean show a toast message if you need.
– Raj
Nov 25 '18 at 12:37
Ok, now I got it. Is there a way to do something similar, when a click occurs outside of the dialog?
– earthling
Nov 25 '18 at 13:35
|
show 1 more comment
You can maintain the state of dialog open/ close in a boolean and handle it. When you open the dialog you make it true and when user clicks back or outside the dialog check that boolean and show the alert pop-up and when dialog closes (dismisses) make boolean to false.
You can maintain the state of dialog open/ close in a boolean and handle it. When you open the dialog you make it true and when user clicks back or outside the dialog check that boolean and show the alert pop-up and when dialog closes (dismisses) make boolean to false.
answered Nov 25 '18 at 9:45
RajRaj
15016
15016
Hello Raj, I am not quite sure how this will work. Do you mean that I should reopen the dialog, when the boolean is a certain value?
– earthling
Nov 25 '18 at 11:26
Can you explain me how the content inside dialog you will be changing and saving in normal case? You will be placing edit text and button in dialog?
– Raj
Nov 25 '18 at 11:39
Hello Raj, exactly. I have a list view, and I open the individual elements of that list view with a dialog. The information of that item can be changed with the dialog.
– earthling
Nov 25 '18 at 12:16
alert.setCancelable(false); // where alert is instance of AlertDialog.Builder - you can use this to disable dialog close when clicking outside the dialog. As already mentioned in order to handle back press you must maintain a boolean when dialog open and close so that when back pressed onBackPressed() override method will be called where you can check boolean show a toast message if you need.
– Raj
Nov 25 '18 at 12:37
Ok, now I got it. Is there a way to do something similar, when a click occurs outside of the dialog?
– earthling
Nov 25 '18 at 13:35
|
show 1 more comment
Hello Raj, I am not quite sure how this will work. Do you mean that I should reopen the dialog, when the boolean is a certain value?
– earthling
Nov 25 '18 at 11:26
Can you explain me how the content inside dialog you will be changing and saving in normal case? You will be placing edit text and button in dialog?
– Raj
Nov 25 '18 at 11:39
Hello Raj, exactly. I have a list view, and I open the individual elements of that list view with a dialog. The information of that item can be changed with the dialog.
– earthling
Nov 25 '18 at 12:16
alert.setCancelable(false); // where alert is instance of AlertDialog.Builder - you can use this to disable dialog close when clicking outside the dialog. As already mentioned in order to handle back press you must maintain a boolean when dialog open and close so that when back pressed onBackPressed() override method will be called where you can check boolean show a toast message if you need.
– Raj
Nov 25 '18 at 12:37
Ok, now I got it. Is there a way to do something similar, when a click occurs outside of the dialog?
– earthling
Nov 25 '18 at 13:35
Hello Raj, I am not quite sure how this will work. Do you mean that I should reopen the dialog, when the boolean is a certain value?
– earthling
Nov 25 '18 at 11:26
Hello Raj, I am not quite sure how this will work. Do you mean that I should reopen the dialog, when the boolean is a certain value?
– earthling
Nov 25 '18 at 11:26
Can you explain me how the content inside dialog you will be changing and saving in normal case? You will be placing edit text and button in dialog?
– Raj
Nov 25 '18 at 11:39
Can you explain me how the content inside dialog you will be changing and saving in normal case? You will be placing edit text and button in dialog?
– Raj
Nov 25 '18 at 11:39
Hello Raj, exactly. I have a list view, and I open the individual elements of that list view with a dialog. The information of that item can be changed with the dialog.
– earthling
Nov 25 '18 at 12:16
Hello Raj, exactly. I have a list view, and I open the individual elements of that list view with a dialog. The information of that item can be changed with the dialog.
– earthling
Nov 25 '18 at 12:16
alert.setCancelable(false); // where alert is instance of AlertDialog.Builder - you can use this to disable dialog close when clicking outside the dialog. As already mentioned in order to handle back press you must maintain a boolean when dialog open and close so that when back pressed onBackPressed() override method will be called where you can check boolean show a toast message if you need.
– Raj
Nov 25 '18 at 12:37
alert.setCancelable(false); // where alert is instance of AlertDialog.Builder - you can use this to disable dialog close when clicking outside the dialog. As already mentioned in order to handle back press you must maintain a boolean when dialog open and close so that when back pressed onBackPressed() override method will be called where you can check boolean show a toast message if you need.
– Raj
Nov 25 '18 at 12:37
Ok, now I got it. Is there a way to do something similar, when a click occurs outside of the dialog?
– earthling
Nov 25 '18 at 13:35
Ok, now I got it. Is there a way to do something similar, when a click occurs outside of the dialog?
– earthling
Nov 25 '18 at 13:35
|
show 1 more comment
user these methods on your dialog view to prevent cancel dialog
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.show();
Thank you for your reply. However, this is not what I am looking for. I want to be able to dismiss the dialog when clicking outside of the dialog, when no infarmation hast changed, so disabling it overall is not an option.
– earthling
Nov 25 '18 at 11:08
add a comment |
user these methods on your dialog view to prevent cancel dialog
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.show();
Thank you for your reply. However, this is not what I am looking for. I want to be able to dismiss the dialog when clicking outside of the dialog, when no infarmation hast changed, so disabling it overall is not an option.
– earthling
Nov 25 '18 at 11:08
add a comment |
user these methods on your dialog view to prevent cancel dialog
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.show();
user these methods on your dialog view to prevent cancel dialog
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.show();
answered Nov 25 '18 at 9:55
madu_devmadu_dev
593
593
Thank you for your reply. However, this is not what I am looking for. I want to be able to dismiss the dialog when clicking outside of the dialog, when no infarmation hast changed, so disabling it overall is not an option.
– earthling
Nov 25 '18 at 11:08
add a comment |
Thank you for your reply. However, this is not what I am looking for. I want to be able to dismiss the dialog when clicking outside of the dialog, when no infarmation hast changed, so disabling it overall is not an option.
– earthling
Nov 25 '18 at 11:08
Thank you for your reply. However, this is not what I am looking for. I want to be able to dismiss the dialog when clicking outside of the dialog, when no infarmation hast changed, so disabling it overall is not an option.
– earthling
Nov 25 '18 at 11:08
Thank you for your reply. However, this is not what I am looking for. I want to be able to dismiss the dialog when clicking outside of the dialog, when no infarmation hast changed, so disabling it overall is not an option.
– earthling
Nov 25 '18 at 11:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466124%2fdialog-confirmation-when-dismissed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown