Figured it out... My custom view had the same ID for its FrameLayout
as was being used for the specific instance of the custom view. The state was being properly saved by the instance and then overwritten (cleared) by the FrameLayout
which had no state to persist.
I also changed its base-class to a RelativeView
which made more sense.
In custom view's XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:id="@+id/addressInput"
android:background="@drawable/rounded_edit">
And the instance usage:
<com.myStuff.AddressInput
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/addressInput"
android:layout_marginTop="10dp"
app:addressMode="Domestic"
app:showSelect="true"
app:showClear="true" />
Changed to: (@+id/addressInput -> @+id/shippingAddress)
<com.myStuff.AddressInput
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/shippingAddress"
android:layout_marginTop="10dp"
app:addressMode="Domestic"
app:showSelect="true"
app:showClear="true" />
Makes you wish there was some scoping for IDs to prevent this kind of thing. Why should you have to know about a custom view's internals to make sure you avoid ID conflict?