I keep getting this error and i'm not sure how to fix it. Can anyone help me? (Starter with programming / Xaramin) PS: The mBtnSignUp.Click += .... code does work + shows the dialog, but the SignIn doesn't, while it's the same code + the code id is correct aswell.
Error: System.NullReferenceException: Object reference not set to an instance of an object.
Part of code thats giving me the error:
mBtnSignIn.Click += (object sender, EventArgs args) =>
{
//Dialog opvragen
FragmentTransaction transaction = FragmentManager.BeginTransaction();
dialog_SignIn signInDialog = new dialog_SignIn();
signInDialog.Show(transaction, "Dialog fragment");
signInDialog.mOnSignInComplete += SignInDialog_mOnSignInComplete;
};
Full Code:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
mBtnSignUp = FindViewById<Button>(Resource.Id.btnRegistreren);
mBtnSignIn = FindViewById<Button>(Resource.Id.btnInloggen);
mProgressBar = FindViewById<ProgressBar>(Resource.Id.progressBar1);
mBtnSignIn.Click += (object sender, EventArgs args) =>
{
//Dialog opvragen
FragmentTransaction transaction = FragmentManager.BeginTransaction();
dialog_SignIn signInDialog = new dialog_SignIn();
signInDialog.Show(transaction, "Dialog fragment");
signInDialog.mOnSignInComplete += SignInDialog_mOnSignInComplete;
};
mBtnSignUp.Click += (object sender, EventArgs args) =>
{
//Dialog opvragen
FragmentTransaction transaction = FragmentManager.BeginTransaction();
dialog_SignUp signUpDialog = new dialog_SignUp();
signUpDialog.Show(transaction, "Dialog fragment");
signUpDialog.mOnSignUpComplete += SignUpDialog_mOnSignUpComplete;
};
}
void SignInDialog_mOnSignInComplete(object sender, OnSignInEventArgs e) //Inloggen
{
mProgressBar.Visibility = ViewStates.Invisible;
Thread thread = new Thread(ActLikeARequest);
thread.Start();
}
void SignUpDialog_mOnSignUpComplete(object sender, OnSignUpEventArgs e) //Registreren
{
mProgressBar.Visibility = ViewStates.Invisible;
Thread thread = new Thread(ActLikeARequest);
thread.Start();
}
private void ActLikeARequest()
{
Thread.Sleep(3000);
RunOnUiThread(() => { mProgressBar.Visibility = ViewStates.Invisible; });
}
I hope my question is understandable.
Thanks in advance!