alert dialog in android should not dismiss(android中的警报对话框不应关闭)
问题描述
我正在制作一个应用程序,其中有一个警报对话框.
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中的警报对话框不应关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:android中的警报对话框不应关闭
基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
