Android 中返回布尔值的 Dialog.Confirm
我需要一个返回布尔值的确认对话框,以提醒用户表单中缺少的一系列值,这些值是根据设置所需的,但不是强制性的。
我做了很多研究,但没有人告诉我如何激活它。
例如:在表单中,假设用户忘记输入城市、州和邮政编码。我需要发出一个提醒,询问用户“你是故意不进入城市的吗?”带有“是”和“否”按钮。如果用户回答“是”,则抛出州的提醒,否则将焦点设置为城市,以便用户可以输入城市。等等......
任何帮助将不胜感激。
谢谢,
文西
I need a Confirm dialog that returns the boolean value in order to remind the user about the missing series of values in the form that are required based on the settings but not mandatory.
I did lot of research but none of the tell me how to active this.
For example: In a form lets say the user forgot to enter City, State and Zip. I need to throw an reminder asking the user "Did you intentionally not enter the City?" with "Yes" and "No" buttons. If the user answers "Yes" then throw the reminder for State else set the focus to City, so that user can enter the city. And so on....
Any help would be greatly appreciated.
Thanks,
Vincy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您提出的用户体验并不是特别友好。使用颜色编码或其他东西来指示您认为应该填写但没有填写的字段,而不是强迫用户必须不断点击对话框来执行用户想做的事情。
话虽如此,请使用
AlertDialog
(可能通过AlertDialog.Builder
)并为按钮设置DialogInterface.OnClickListener
对象。根据按钮选择,您可以设置焦点(通过requestFocus()
,在需要焦点的小部件上调用)或继续处理。First, what you are proposing is not a particularly friendly UX. Use color coding or something to indicate fields that you think should be filled in but are not, rather than forcing the user to have to keep tapping on dialogs to do what the user wants to do.
All that being said, use
AlertDialog
(perhaps viaAlertDialog.Builder
) and set upDialogInterface.OnClickListener
objects for the buttons. Depending upon the button choice, you either set the focus (viarequestFocus()
, called on the widget needing focus) or continue with your processing.