在不按下按钮的情况下关闭AlertDialog
问题描述:
我想通过Socket建立与服务器的连接,而手机正试图建立连接时,我想在没有连接时关闭的按钮的情况下调出AlertDialog成立。在不按下按钮的情况下关闭AlertDialog
private void attempToSendXML(AlertDialog.Builder builder, String profile) {
SocketClient client = new SocketClient();
Alerts.establishConnection(builder);
connectionEstablished = client.createClient(server, port);
//Close the Dialog here!
if (!connectionEstablished) {
connectionRefusedAlert(builder);
return;
}
答
您可能想阅读过程对话框手册中的部分。它们也是警告对话框。
http://developer.android.com/guide/topics/ui/dialogs.html#ProgressDialog
AlertDialog.Builder返回具有.close()函数的对象。用它来关闭对话框。