In my activity I have this:
mBtnSignUp.Click += (object sender, EventArgs e) =>
{
//Pull up dialog
FragmentTransaction transaction = FragmentManager.BeginTransaction();
dialog_SignUp signUpDialog = new dialog_SignUp();
signUpDialog.Show(transaction, "dialog fragment");
signUpDialog.mOnSignUpComplete += signUpDialog_mOnSignUpComplete;
};
void signUpDialog_mOnSignUpComplete (object sender, OnSignUpEventArgs e)
{
Thread thread = new Thread (ActLikeARequest);
thread.Start ();
}
private void ActLikeARequest()
{
Thread.Sleep (3000);
}
And in Dialog
I have:
public class OnSignUpEventArgs : EventArgs
{
private string mFirstName;
private string mEmail;
private string mPassword;
public string FirstName
{
get{ return mFirstName; }
set{ mFirstName=value;}
}
public string Email
{
get{ return mEmail; }
set{ mEmail=value;}
}
public string Password
{
get{ return mPassword; }
set{ mPassword=value;}
}
public OnSignUpEventArgs (string firstName, string email, string password) : base()
{
FirstName = firstName;
Email = email;
Password = password;
}
}
class dialog_SignUp:DialogFragment
{
private Button mBtnSignUp;
private EditText mFirstName;
private EditText mEmail;
private EditText mPassword;
public event EventHandler<OnSignUpEventArgs> mOnSignUpComplete;
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
base.OnCreateView (inflater, container, savedInstanceState);
var view = inflater.Inflate (Resource.Layout.dialog_sign_up, container, false);
mBtnSignUp = view.FindViewById<Button> (Resource.Id.btnDialogEmail);
mFirstName = view.FindViewById<EditText> (Resource.Id.txtFirstName);
mEmail = view.FindViewById<EditText> (Resource.Id.txtEmail);
mPassword = view.FindViewById<EditText> (Resource.Id.txtPassword);
mBtnSignUp.Click += mBtnSignUp_Click;
return view;
}
void mBtnSignUp_Click (object sender, EventArgs e)
{
//User has clicked the sign up button
mOnSignUpComplete.Invoke (this, new OnSignUpEventArgs(mFirstName.Text, mEmail.Text, mPassword.Text));
this.Dismiss ();
}
public override void OnActivityCreated (Bundle savedInstanceState)
{
Dialog.Window.RequestFeature (WindowFeatures.NoTitle); //Sets the title bar to invisible
base.OnActivityCreated (savedInstanceState);
Dialog.Window.Attributes.WindowAnimations = Resource.Style.dialog_animation; //Set the animation
}
}
The question is, how do I pass string data to my Dialog
, so when it is called, TextViews (mFirstName, mEmail, mPassword)
get Text = *strings passadas*
?