示例#1
0
        private void fabClicked(object sender, EventArgs args)
        {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
            var inflater    = this.LayoutInflater;
            var childLayout = inflater.Inflate(Resource.Layout.dialog_main, null);

            alertDialog.SetView(childLayout)
            //set event to null so alertdialog won't be destroyd on button click
            .SetPositiveButton(Resource.String.ok, (EventHandler <DialogClickEventArgs>)null)
            .SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null);
            var dialog = alertDialog.Create();

            dialog.Show();

            var positiveButton = dialog.GetButton((int)DialogButtonType.Positive);

            positiveButton.Click += delegate
            {
                var groupName   = childLayout.FindViewById <EditText>(Resource.Id.dialog_group).Text;
                var playersText = childLayout.FindViewById <EditText>(Resource.Id.dialog_players).Text;
                if (mainPresenter.FabOkClicked(groupName, playersText))
                {
                    dialog.Dismiss();
                }
            };
        }