I am using an AlertDialog that is very simple, just a custom view with a text box, and the alertdialog positive submit button. I would like to validate that the text box has had text entered before the user dismisses the dialog. I see two possibilities, with questions about each:
- Disable the submit button until the
text box is not empty (in some
onChange() type handler for the text
box)
- How do you know when the content of the text box changes?
- How do you get a reference to the AlertDialog's button object?
- Check in the submit button's
onClick() and cancel the dismissing
of the dialog if it's empty.
- Is it possible to do this with an AlertDialog's button? The dialog dismisses without manually calling dismiss() or cancel(), so I'm not sure...
Is either of these options possible with an AlertDialog (vs a custom dialog)?
I think the second option would be the simplest, but I'm up for either if it's possible.