I am trying to pop a dialog fragment on the loginscreenactivity onclick a button which has the register form.
I am pretty sure that the dialog is opening but i am not able to inflate it properly.
when a button is clicked for the DialogFragment
something appears but it is blank completely, wherein I am expecting a layout that I have created for register form.
I've read the code keenly, I don't seem to find the problem.
Here is my DialogFragment
class dialog_fragment:DialogFragment
{
private Button btn;
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return base.OnCreateView(inflater, container, savedInstanceState);
var view = inflater.Inflate(Resource.Layout.Register, container, false);
btn = view.FindViewById<Button>(Resource.Id.btnRegister);
btn.Click += delegate
{
Toast.MakeText(this.Activity, "something", ToastLength.Long).Show();
};
return view;
}
}
This I include where I am showing the dialog
btnRegister.Click += delegate
{
FragmentTransaction ft = FragmentManager.BeginTransaction();
dialog_fragment signup = new dialog_fragment();
signup.Show(ft,"dialog signup");
};
the solution might be very dumb, thanks in advance
Vaibhav, as you were expecting, the solution is dumb but this happens.
you have dialog fragment that is supposed to return a dialog, but sadly there are two returns in the dialogfragment class.
your solution here.
no wonder it will not return anything on base.OnCreateView(inflater, container, savedInstanceState);
you don't ever meet line var view = inflater.Inflate(Resource.Layout.Register, container, false);
remove the return before base.OnCreateView()
class dialog_fragment:DialogFragment
{
private Button btn;
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
//return
base.OnCreateView(inflater, container, savedInstanceState);
var view = inflater.Inflate(Resource.Layout.Register, container, false);
btn = view.FindViewById<Button>(Resource.Id.btnRegister);
btn.Click += delegate
{
Toast.MakeText(this.Activity, "something", ToastLength.Long).Show();
};
return view;
}
}