我的按钮onClick流程在Xamarin Android中不起作用

时间:2019-03-15 00:25:57

标签: android xamarin xamarin.android

我的其他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

    }

1 个答案:

答案 0 :(得分:1)

首先确保 Resource.Id.buttonRegister 是您按钮的ID

您创建 EventHandler 的时间:

  btncreate = FindViewById