I have a button that I want to clear certain fields after it is pressed. I have a button event that is supposed to display a question before the clear functionality is implemented. After the user confirms they want to clear the button then the button will clear the text in the fields. However, as of now the dialog isn't displaying. Below is a sample of my Clear Button function. Please let me know if you see anything I am not seeing.
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 = ""; }; }
Resource.Id.cmdConfirmOKClick event and see if the delegate is getting triggered when you click the button? I think it may have to do with the fact that you're attaching a delegate withinbtnPalletClear_Clickpublic bool ClearClicked = false;at the class level, then when clear is clicked doClearClicked = true. Then attach thecmdConfirmOKevent from outside thebtnPalletClear_Clickmethod and insidecmdConfirmOKcheckif (ClearClicked) { ... do your stuff here ... then ClearClicked = false; }or something like that. Just guessing