首页 > 解决方案 > 尝试创建未触摸的警报对话框时出错

问题描述

我正在创建一个警报对话框,一旦它显示在屏幕上就无法禁用,该过程工作但中途因为我遇到问题,当显示警报对话框时它不会停用,但此时按下任何按钮一个动作,动作被激活,我可以移动屏幕。
这是我的 .cs:

private void ProgressBar()
{
    int padding = 30;
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.Orientation = Android.Widget.Orientation.Horizontal;
    linearLayout.SetPadding(padding, padding, padding, padding);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);

    ProgressBar progress = new ProgressBar(this);
    progress.SetPadding(0, 0, 0, 0);

    LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
    layout.Gravity = GravityFlags.Center;
    TextView textView = new TextView(this);
    textView.Text = "Enviando...";
    textView.SetTextColor(Color.ParseColor("#000000"));
    textView.TextSize = 20;

    linearLayout.AddView(progress);
    linearLayout.AddView(textView);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.SetCancelable(true);
    builder.SetView(linearLayout);

    AlertDialog dialog = builder.Create();
    dialog.Show();

    dialog.Window.SetFlags(WindowManagerFlags.NotTouchable, WindowManagerFlags.NotTouchable);
}

标签: xamarinxamarin.android

解决方案


推荐阅读