1

我有一个问题AlertDialog

如果用户点击正面按钮,我希望我AlertDialog返回,如果他点击负面按钮,我希望返回。true该功能必须阻止程序,直到用户单击按钮。

我的代码:

    isSuspended = true;
public boolean alertDialog(){
    final EditText input = new EditText(context);
        new AlertDialog.Builder(context)
        .setView(input)
        .setPositiveButton("Authenticate", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                    if (isValid != 1) {
                    dialog.cancel();
                    ShowAlert.showAlertMessage(context, "title",
                            "Wrong Password!!!");
                    isSuspended = true;
                } else {
                    dialog.cancel();
                    ShowAlert.showAlertMessage(context, "title",
                            "Correct Password!!!");
                    isSuspended = true;
                }
                dialog.cancel();
            }
        })
        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
            isSuspended=false;
                dialog.cancel();
            }
        }).show();
return isSuspended;
}
4

0 回答 0