我在一周前开始使用Xamarin Studio工作,但是遇到了一个问题:我创建了一个edittext,其中包含序列号。 我想在按下Enter后运行一个函数。 当我按下Enter时,函数可以正常运行,但我无法修改edittext的内容(无法在其中输入)。
代码:
EditText edittext_vonalkod = FindViewById<EditText>(Resource.Id.editText_vonalkod);
edittext_vonalkod.KeyPress += (object sender, View.KeyEventArgs e) =>
{
if ((e.Event.Action == KeyEventActions.Down) && (e.KeyCode == Keycode.Enter))
{
//Here is the function
}
};
这是控制器的代码:
<EditText
p1:layout_width="wrap_content"
p1:layout_height="wrap_content"
p1:layout_below="@+id/editText_dolgozo_neve"
p1:id="@+id/editText_vonalkod"
p1:layout_alignLeft="@+id/editText_dolgozo_neve"
p1:hint="Vonalkód"
p1:text="1032080293"
p1:layout_toLeftOf="@+id/editText_allapot" />
我尝试使用带有参数的edittext_vonalkod.TextCanged
,但遇到问题。我可以修改文本内容,但无法处理Enter键。
谢谢!