I've been searching for a while now but I think most of the reported bugs (and there are quite a few) in android.support.design.widget.TextInputLayout
differ a little from this one. At least, I have solved most of the other bugs, but struggle with this one.
I currently have a Fragment
in my activity with a couple of TextInputLayout
like this
<android.support.design.widget.TextInputLayout
android:id="@+id/input1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint1"
android:inputType="numberSigned" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input2
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint2"
android:inputType="numberSigned"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint3"
android:inputType="numberSigned">
</android.support.design.widget.TextInputLayout>
And, after meeting some external condition (not important) I open and show another fragment (100% screen) which hides the aforementioned fragment. In case you wonder this new fragment asks for some extra fields that I need in that particular case.
This is the code that handles the creation of the new Fragment
:
Fragment2 fragment2 = new Fragment2();
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction()
.replace(((ViewGroup) getView().getParent()).getId(), fragment2);
transaction.addToBackStack(Fragment1.class.getSimpleName());
transaction.commit();
BUT the problem is that, when going back (back button press, toolbar/action bar home button, etc..) to the first fragment. All of my TextInputLayouts
lose the text that was inserted on them. This is really annoying and didn't happened when working exclusively with EditText
, like we did previous our Material Design transition.
Moreover, this does not happen if instead of replacing fragments using a FragmentTransaction
, I start a new Activity
. Unfortunately, this is not what we really want. And we shouldn't need to do this kind of workaround.
Any ideas? Has this happened to anyone?