C# 警报对话框未显示

C# 警报对话框未显示,c#,android,android-alertdialog,C#,Android,Android Alertdialog,我有一个解析器,它将值作为字符串抓取,如果它不等于预期值,则调用下面的函数。只有下面的函数不做任何操作,它到达builder.show(),然后跳回我的解析器。它不会显示该对话框,因为如果显示该对话框,则在选择“确定”按钮时,它将在代理上点击finish()。关于可能导致此问题的原因的任何想法。我不知道我是否有一些语法错误,或者是什么问题?我感谢所有的帮助 private void errorReturnReader(string val) { string messag

我有一个解析器,它将值作为字符串抓取,如果它不等于预期值,则调用下面的函数。只有下面的函数不做任何操作,它到达builder.show(),然后跳回我的解析器。它不会显示该对话框,因为如果显示该对话框,则在选择“确定”按钮时,它将在代理上点击finish()。关于可能导致此问题的原因的任何想法。我不知道我是否有一些语法错误,或者是什么问题?我感谢所有的帮助

private void errorReturnReader(string val)
    {
        string message = "";
        if (val != "")
        {
            AlertDialog.Builder builder;
            builder = new AlertDialog.Builder (this,3);
            builder.SetTitle("Institution Status Error");
            builder.SetCancelable(false);
            builder.SetPositiveButton("OK", delegate { Finish(); });

            switch (val)
            {
            case "NO_KEY":
                message = "The Key passed does not exist.";
                break;
            case "NO_EMP":
                message = "The employee id does not exist in the specified institution.";
                break;
            case "NO_INST":
                message = "The Institution code associated with key does not exist.";
                break;
            case "NO_BRANCH":
                message = "The Branch value passed does not exist.";
                break;
            case "EMP_EXCL":
                message = "Employee is excluded from all branches.";
                break;
            case "NO_STAT":
                message = "No audit records were found for the branch.";
                break;
            case "NO_RESPONSE":
                message = "No status was returned";
                break;
            case "NO_COMM":
                message = "The Cloud has not communicated with the Console within 60 seconds. Can not verify status.";
                break;
            default:
                break;
            }
            builder.SetMessage(message);
            builder.Create ();
            builder.Show ();
        }
    }

对于字符串比较,请使用
.equals()
,即。 改变

有关更多信息,请参阅

同时要显示对话框,请更改

 builder.Create ();
 builder.Show ();


有关更多信息,请参见

尝试以下操作:builder.Create().show();我在发帖前也试过了,结果没有改变。我感谢你的答复。
 if (!"".equals(val))
 if (val.length() != 0)
 builder.Create ();
 builder.Show ();
 builder.create().show();