Android Disable Positive Button On Some Condion In Addtextchangedlistener (editext)
Here is my code for a dialog, I want to disable positive button if text size in edit-text in greater than 5 and enable it if size <= 5 private void myDialog(String title) {
Solution 1:
Try something like this:
@OverridepublicvoidafterTextChanged(Editable s) {
if (s.length() > 5) {
dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
} else {
dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(true);
}
}
where dialog
is:
finalAlertDialogdialog= builder.create();
Post a Comment for "Android Disable Positive Button On Some Condion In Addtextchangedlistener (editext)"