I’ve got three tabs, all from a layout xml file,say list.xml. In list.xml I’ve defined a EditText, something like this:
<EditText
android:id="@+id/filterText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/filterClear"
android:hint="@string/filterHint"
android:text="@string/filter">
</EditText>
However, it seems that if doing a orientation change and having typed something into one of the three EditTexts (all I guess with the same ID), the text doesn’t restore to the same state. Sometimes (depending on which tab I’ve typed into) all fields are empty or all fields are filled.
What is the proper way to handle this?
I ended up having three separate layout files
list1.xml,list2.xml,list3.xml, that only differed in the IDs. Solist1.xmlwould have@+id/filterText1,list2.xmlwould have@+id/filterText2and so on.And then in the
ListActivity.javafile I used to have this as part of my onCreate:And several references to this throughout the activity:
…
Instead I have now got this in my onCreate:
And this when referencing the field itself throughout the activity: