I have a simple DialogFragment
with a custom view that contains 1 EditText
. During OnCreateDialog
I read the arguments that I've already passed to the fragment and with these arguments I set the text of the EditText
.
public class InsuredFragment : Android.Support.V4.App.DialogFragment
{
public override Dialog OnCreateDialog(Bundle savedInstanceState)
{
var inflater = (LayoutInflater)Activity.GetSystemService(Context.LayoutInflaterService);
var view = inflater.Inflate(Resource.Layout.InsuredLayout, null);
var txtFirstName = view.FindViewById<EditText>(Resource.Id.txtFirstName);
if (txtFirstName != null)
{
txtFirstName.Text = Arguments.GetString("firstname");
}
} }
Let's say that the argument firstname is "abc". The dialog is displayed correctly. The user then changes the EditText to "abcd".
After that, the user rotates the device, so the OnCreateDialog is called again. At this point, the arguments is null, so the EditText's text is set to null. However when the dialogfragment is shown to the user, the EditText's text is correctly set to "abcd", although I've set it to null inside OnCreateDialog.
So, I see that it works as I want to, but I need to understand why the EditText contains the correct value, although I've set it to null. Does EditText retains its value on orientation change and ignores my value?
Thank you!