Event handler

Hello, could tell how to add an event-per-click on buttons.
http://s017.radikal.ru/i437/1412/92/0082f6b2f520.jpg
My apologize for fulish qustion!

Best Answers

Answers

  • AzamatDAzamatD RUMember

    Could you explain me what in parametrs here?
    button1.Click += (s, e), I mean s, e
    Thank you!

  • AzamatDAzamatD RUMember
    edited December 2014
    public bool test(Action<bool> callBack  )
        {
            var button1 = FindViewById<Button> (Resource.Id.button1);
            var button2 = FindViewById<Button> (Resource.Id.button2);
    
            button1.Click += ((object sender, EventArgs e) =>     {
                AlertDialog.Builder DiologWithUser1 = new AlertDialog.Builder (this);
    
                DiologWithUser1.SetTitle(Android.Resource.String.DialogAlertTitle);
                DiologWithUser1.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                DiologWithUser1.SetMessage("Начинается учёт посещаемости сотрудников");
                DiologWithUser1.SetPositiveButton("OK",(object sender, EventArgs e)=>
                    {
                        callBack(true);
    
    
                    });
                DiologWithUser1.SetNegativeButton("No",(object sender, EventArgs e) => 
                    {
                        callBack(false);
    
                    });
    
                DiologWithUser1.Show();
    
            });
    

    Do me a favor!
    This MessabeBox on Xamarin Could you tell why IDE give me errors in this line
    DiologWithUser1.SetPositiveButton("OK",(object sender, EventArgs e)=>
    What have to be in arguments here?
    I appreciate for you help

  • AzamatDAzamatD RUMember
    edited December 2014

    Once corrected the syntaxis errors, app not load forms in device, but in Main.axml they are exist.

        public bool test(Action<bool> callBack  )
        {
            var button1 = FindViewById<Button> (Resource.Id.button1);
            var button2 = FindViewById<Button> (Resource.Id.button2);
            bool yesornot = false;
    
            button1.Click += (s,e) =>     {
                AlertDialog.Builder DiologWithUser1 = new AlertDialog.Builder (this);
    
                DiologWithUser1.SetTitle(Android.Resource.String.DialogAlertTitle);
                DiologWithUser1.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                DiologWithUser1.SetMessage("Начинается учёт посещаемости сотрудников");
                DiologWithUser1.SetPositiveButton("OK",(ss,ee)=>
                    {
                        callBack(true);
                        yesornot=true;
    
    
                    });
                DiologWithUser1.SetNegativeButton("No",(ss,ee) => 
                    {
                        callBack(false);
                        yesornot=false;
                    });
    
                DiologWithUser1.Show();
    
    
            };
            return yesornot;
    
        }
    

    http://s58.radikal.ru/i160/1412/bb/b0b9bf2b74e0.jpg
    http://s020.radikal.ru/i713/1412/93/a0400f5a0508.png

Sign In or Register to comment.