0

I have the following code for an Android app in C#

using Android.App;
using Android.Widget;
using Android.OS;

namespace Practicum1
{
    [Activity(Label = "Practicum 1.2.1", MainLauncher = true)]
    public class MainActivity : Activity
    {
        EditText invullen;
        TextView displaynaam;


        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            TextView begintekst;
            begintekst = new TextView(this);
            begintekst.Text = "Vul je naam in!";

            invullen = new EditText(this);
            invullen.TextChanged += naam_textChanged;

            displaynaam = new TextView(this);
            displaynaam.Text = "Hier kom je naam te staan";


            LinearLayout stapel;
            stapel = new LinearLayout(this);
            stapel.Orientation = Orientation.Vertical;

            stapel.AddView(begintekst);
            stapel.AddView(invullen);
            stapel.AddView(displaynaam);



            // Set our view from the "main" layout resource
            this.SetContentView(stapel);
        }
        private void naam_textChanged(object sender, ItemEventArgs ea)
        {
            displaynaam.Text = "Welkom " + invullen.Text;
        }
    }
}

But then I get the following error message: 'No overload for naam_textChanged matches delegate EventHandler

Does anyone know how to solve this?

Regards, Joren

jorenwouters
  • 105
  • 1
  • 1
  • 8

1 Answers1

0

Your event arguments are not correct. It should look like this.

private void naam_TextChanged (object sender, TextChangedEventArgs e)
{

}

Check documentation of EditText

Point 4) Implement the TextChanged event to capture the text from the EditText and write it to the TextView.

editText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {

       textView.Text = e.Text.ToString ();

};
mybirthname
  • 17,949
  • 3
  • 31
  • 55