如何验证用户是否在警告对话框中输入了任何按钮
How to verify if the user has enterd any button on alert dialog box or not
我有两个按钮的警告对话框
一种。好的
b.否
如果用户按下确定,则执行某些操作
否则执行其他操作。
我正在寻找的是检查用户是否输入了任何按钮
如果他还没有,几秒钟后我想发送一些消息。
有人能帮我解决这个问题吗??
您可以在 AlertDialog.show()
方法后使用 Timer。
yourDialog.show();
final Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
if (yourDialog.isShowing()) {
// Send some message
timer.cancel();
}
}
}, 2000); // Seconds in milliseconds
另请检查此问题以了解其他可能性:
Android close dialog after 5 seconds?
我有两个按钮的警告对话框 一种。好的 b.否
如果用户按下确定,则执行某些操作 否则执行其他操作。
我正在寻找的是检查用户是否输入了任何按钮 如果他还没有,几秒钟后我想发送一些消息。 有人能帮我解决这个问题吗??
您可以在 AlertDialog.show()
方法后使用 Timer。
yourDialog.show();
final Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
if (yourDialog.isShowing()) {
// Send some message
timer.cancel();
}
}
}, 2000); // Seconds in milliseconds
另请检查此问题以了解其他可能性: Android close dialog after 5 seconds?