Android 中返回布尔值的 Dialog.Confirm

发布于 2024-12-08 19:03:22 字数 255 浏览 0 评论 0原文

我需要一个返回布尔值的确认对话框,以提醒用户表单中缺少的一系列值,这些值是根据设置所需的,但不是强制性的。

我做了很多研究,但没有人告诉我如何激活它。

例如:在表单中,假设用户忘记输入城市、州和邮政编码。我需要发出一个提醒,询问用户“你是故意不进入城市的吗?”带有“是”和“否”按钮。如果用户回答“是”,则抛出州的提醒,否则将焦点设置为城市,以便用户可以输入城市。等等......

任何帮助将不胜感激。

谢谢,

文西

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↙温凉少女 2024-12-15 19:03:22

首先,您提出的用户体验并不是特别友好。使用颜色编码或其他东西来指示您认为应该填写但没有填写的字段,而不是强迫用户必须不断点击对话框来执行用户想做的事情。

话虽如此,请使用 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 via AlertDialog.Builder) and set up DialogInterface.OnClickListener objects for the buttons. Depending upon the button choice, you either set the focus (via requestFocus(), called on the widget needing focus) or continue with your processing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文