diff --git a/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/TreehouseLayout.kt b/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/TreehouseLayout.kt index 80b8f9a915..272ac269c9 100644 --- a/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/TreehouseLayout.kt +++ b/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/TreehouseLayout.kt @@ -25,6 +25,7 @@ import androidx.activity.OnBackPressedDispatcher as AndroidOnBackPressedDispatch import app.cash.redwood.treehouse.TreehouseView.ReadyForContentChangeListener import app.cash.redwood.treehouse.TreehouseView.WidgetSystem import app.cash.redwood.widget.RedwoodLayout +import app.cash.treehouse.host.R import java.util.UUID @Deprecated( @@ -57,6 +58,11 @@ public class TreehouseLayout( override var saveCallback: TreehouseView.SaveCallback? = null + init { + // The view needs to have an ID to participate in instance state saving. + id = R.id.treehouse_layout + } + override fun onAttachedToWindow() { super.onAttachedToWindow() readyForContent = true diff --git a/redwood-treehouse-host/src/androidMain/res/values/ids.xml b/redwood-treehouse-host/src/androidMain/res/values/ids.xml new file mode 100644 index 0000000000..677db48916 --- /dev/null +++ b/redwood-treehouse-host/src/androidMain/res/values/ids.xml @@ -0,0 +1,18 @@ + + + + diff --git a/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchActivity.kt b/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchActivity.kt index bd1c2694b0..1ee6180be2 100644 --- a/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchActivity.kt +++ b/samples/emoji-search/android-views/src/main/kotlin/com/example/redwood/emojisearch/android/views/EmojiSearchActivity.kt @@ -75,8 +75,6 @@ class EmojiSearchActivity : ComponentActivity() { } treehouseLayout = TreehouseLayout(this, widgetSystem, onBackPressedDispatcher).apply { - // The view needs to have an id for Android to populate saved data back - this.id = 9000 treehouseContentSource.bindWhenReady(this, treehouseApp) } setContentView(treehouseLayout)