我的其他buttons
正在工作,而这个button
只是不起作用。
这是我的代码片段:
public class RegisterActivity : Activity
{
EditText txtfullname;
EditText txtaddress;
EditText txtusername;
EditText txtpassword;
EditText txtconfirmpass;
Button btncreate;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.registerPage);
txtfullname = FindViewById<EditText>(Resource.Id.editTextFullname);
txtaddress = FindViewById<EditText>(Resource.Id.editTextAddress);
txtusername = FindViewById<EditText>(Resource.Id.editTextUsername);
txtpassword = FindViewById<EditText>(Resource.Id.editTextPassword);
txtconfirmpass = FindViewById<EditText>(Resource.Id.editTextConfirmPassword);
btncreate = FindViewById<Button>(Resource.Id.buttonRegister);
btncreate.Click += Btncreate_Click; //this doesn't get process even though I have an onclick of it
}
首先确保Resource.Id.buttonRegister
是你的按钮ID
第二,你创造了EventHandler
:
btncreate = FindViewById<Button>(Resource.Id.buttonRegister);
btncreate.Click += Btncreate_Click;
private void Btncreate_Click(object sender, EventArgs e)
{
//do something when click the button
}