1

I want to keep AlertDialog focused until a user presses any of the buttons on it. In other words, even if a user presses any other area (like it's parent area) or presses back button, dialog must still remain focused. Please let me know which Android 4.0 API method to use.

Thanks much in advance.

lupchiazoem
  • 8,026
  • 6
  • 36
  • 42

1 Answers1

4

use setCancelable(false); It will stop removing your AlertDialog from your screen.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
  • 2
    I had used exactly same but, I do not see any difference. So, I raised this question. Please see my earlier post - "AlertDialog's setCancelable(false) method not working" @ [http://stackoverflow.com/questions/8906269/alertdialogs-setcancelablefalse-method-not-working]. – lupchiazoem Jan 19 '12 at 03:41
  • All - As it might help you so, providing this info - I was calling `setCancelable(false)` on `AlertDialog` which was in `DialogFragment` class. And, this was the reason for my code failure. From DialogFragment class description - "This fragment contains a Dialog object, which it displays as appropriate based on the fragment's state. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog.". A related query @ [http://stackoverflow.com/questions/8906269/alertdialogs-setcancelablefalse-method-not-working]. – lupchiazoem Jan 19 '12 at 06:14