FindViewById not displaying id



我有一个按钮,我想在按下后清除某些字段。我有一个按钮事件,它应该在实现clear功能之前显示一个问题。用户确认要清除该按钮后,该按钮将清除字段中的文本。但是,截至目前,该对话框尚未显示。下面是我的Clear Button函数示例。如果你看到我没有看到的东西,请告诉我。

void btnPalletClear_Click(object sender, EventArgs e)
{
dialog = new Dialog(this, Android.Resource.Style.ThemeHoloLightDialogNoActionBarMinWidth);
View myView = View.Inflate(this, Resource.Layout.confirmation_dialog, null);
myView.FindViewById<TextView>(Resource.Id.txtConfirmTitle).Text = "Clear Pallet";
myView.FindViewById<TextView>(Resource.Id.txtConfirmMessage).Text = "Are you sure?";
myView.FindViewById<LinearLayout>(Resource.Id.llQuantity).Visibility = ViewStates.Gone;
myView.FindViewById<Button>(Resource.Id.cmdConfirmCancel).Click += delegate { dialog.Dismiss(); };
myView.FindViewById<Button>(Resource.Id.cmdConfirmOK).Click += delegate
{
dialog.SetContentView(myView);
dialog.Show();
txtPalletUNQ.Text = "";
adapter.lstPallet.Clear();
adapter.NotifyDataSetChanged();
txtPalletVTPID.Text = "";
};
}

我剪切了对话框。SetContentView(myview(和对话框。显示((并将其粘贴到cmdConfirmOk的外部,它就修复了它。

最新更新