[英]C# CS0123: No overload for matches delegate Eventhandler
I have the following code for an Android app in C# 我在C#中为Android应用程序提供了以下代码
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 但后来我收到以下错误消息:'naam_textChanged没有重载匹配委托EventHandler
Does anyone know how to solve this? 有谁知道如何解决这个问题?
Regards, Joren 问候,乔仁
Your event arguments are not correct. 您的事件参数不正确。 It should look like this. 它看起来应该是这样的。
private void naam_TextChanged (object sender, TextChangedEventArgs e)
{
}
Check documentation of EditText 检查EditText的文档
Point 4) Implement the TextChanged
event to capture the text from the EditText
and write it to the TextView
. 要点4)实现TextChanged
事件以从EditText
捕获文本并将其写入TextView
。
editText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
textView.Text = e.Text.ToString ();
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.