我正在制作一个应用程序,其中有一个警报对话框.
I am making an application and it has an Alert Dialog in it.
现在我正在检查我在对话框正按钮 OnClick 方法中从 AlertDialog editTexts 获得的一些数据,但如果我从 edittext 字段获得的数据正确与否,对话框总是会关闭.
Now i am checking some data I got from AlertDialog editTexts in dialog Positive button OnClick method but the dialog always dismiss if data i got from edittext fields is correct or not.
我们如何禁用此功能.
更新:
我正在从对话框中获取 Pin 码和确认 Pin 码,在 onPositive 单击中我已检查以验证 pin 码.
I am gettin Pin Code and Confirm Pin Code from the Dialog Box and in onPositive click i have checked to verify the pin codes.
现在,如果 pin 码匹配,则调用 dialog.dismiss(),如果不匹配,则显示 Toast.
Now if the pin codes matches then it is calling dialog.dismiss() and if not matching then display a Toast.
但如果密码不匹配,它会向我显示消息并关闭对话框.
But in case of pin code not matched it displays me the message and dismiss the dialog.
我不希望这样的事情发生.
I dont want that to be happen.
更多更新:
有什么方法可以禁用确定"按钮,并在验证数据后启用肯定按钮?
is there any way that i will disable the OK Button and when data is verified it will enable the positive Button??
请帮忙
Cap.谢谢你的帮助.通过您的指南,我知道我可以禁用警报对话框按钮.是的!可以禁用按钮.
Cap. Thanks for your help. through your guides i have got to know that i can disable the Alert Dialog Button. YES! its possible to disable the buttons.
答案是:
我们可以使用以下方法禁用按钮:
we can disable the button using:
Button pos = Dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
pos.setEnabled(true);
这篇关于android中的警报对话框不应关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!