带有警告消息的 Android 警报对话框
我有一个带有 EditText 的警报对话框,我想在输入的输入文本为空时警告用户。所以要么: - 通过在当前警报对话框的顶部打开一个新的警报对话框,但不关闭当前警报对话框。我尝试了一下,但不知道该怎么做。 - 通过动态更改我的警报对话框上的消息,但我又不知道如何
I have an alert dialog with an EditText in it and I'd like to warn the user when the entered input text is empty. So either :
- by opening a new alert dialog on the top of the current one, but without closing the current one. I tried it and I don't know how to it.
- by changing dynamically the message on my alert dialog, but again I don't how
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下:
这只是一个简单的弹出对话框,但应该足以满足您的需求。您可以将“Toast.LENGTH_SHORT”更改为“Toast.LENGTH_LONG”,具体取决于您希望对话框保持可见的时间,之后它将消失。
或者更全面的解决方案:
Try giving this a shot:
It's just a simple popup dialog but it should suffice for your needs. You can change 'Toast.LENGTH_SHORT' to 'Toast.LENGTH_LONG' depending on how long you want the dialog to stay visible, after which it will fade away into oblivion.
Or for a more comprehensive solution:
当您为
AlertDialog
设置按钮时,您可以做您想做的事情,例如:You could do what you want when you set the buttons for your
AlertDialog
like: