J'ai cherché un certain temps maintenant mais je pense que la plupart des bogues rapportés (et il y en a un certain nombre) dans android.support.design.widget.TextInputLayout
diffèrent un peu de celui-ci. Au moins, j'ai résolu la plupart des autres bugs, mais luttons avec celui-ci. J'ai actuellement un Fragment
dans mon activité avec un couple de TextInputLayout
comme celui-ciAndroid TextInputLayouts perdre du texte/contenu en revenant dans la transaction de fragment
<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>
Et, après avoir rencontré une certaine condition extérieure (pas important) j'ouvre et montrer un autre fragment (écran à 100%) qui cache le fragment mentionné ci-dessus . Au cas où vous vous demandez ce nouveau fragment demande des champs supplémentaires dont j'ai besoin dans ce cas particulier. C'est le code qui gère la création du nouveau Fragment
:
Fragment2 fragment2 = new Fragment2();
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction()
.replace(((ViewGroup) getView().getParent()).getId(), fragment2);
transaction.addToBackStack(Fragment1.class.getSimpleName());
transaction.commit();
mais le problème est que, lors du passage de retour (appuyez sur le bouton arrière, barre d'outils/Barre d'action bouton d'accueil, etc ..) au premier fragment . Tous mes TextInputLayouts
perdent le texte qui a été inséré sur eux. Ceci est vraiment ennuyeux et n'est pas arrivé en travaillant exclusivement avec EditText
, comme nous l'avons fait précédemment notre transition Material Design.
De plus, cela ne se produit pas si au lieu de remplacer les fragments en utilisant un FragmentTransaction
, je commence un nouveau Activity
. Malheureusement, ce n'est pas ce que nous voulons vraiment. Et nous ne devrions pas avoir besoin de faire ce genre de solution de contournement.
Des idées? Est-ce arrivé à quelqu'un?
Je perds toutes mes données texte lors d'un changement d'orientation. Je ne m'éloigne même pas du fragment. Juste un changement d'orientation, et je perds toutes les données. Est-ce que quelqu'un a fait face à ce problème avec 'TextInputLayout'? Y a-t-il une solution à cela? –
Bon travail! Merci! – Andy