You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: samples/tutorial/Tutorial1.md
+9-5Lines changed: 9 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,10 +91,10 @@ data class WelcomeScreen(
91
91
)
92
92
```
93
93
94
-
Then we need to create a `ViewFactory` that knows how to create an Android `View` to draw the actual screen. The easiest way to create a `ViewFactory` is to create a layout runner. A layout runner is a class that has a reference to the view and knows how to update the view given an instance of a screen. In a typical app, every screen will have a layout runner. Layout runners can also work with AndroidX `ViewBinding`s, which we'll use to define the `WelcomeLayoutRunner`. We have a pre-built `WelcomeViewBinding` that you can use. This binding will be autogenerated from layout files in `tutorials-views` when you first build the app. If Android Studio does not automatically find the file, you can manually import it `import workflow.tutorial.views.databinding.WelcomeViewBinding
95
-
`. However if you would like to create and lay out the view yourself instead, feel free to do so!
94
+
Then we need to create a `ViewFactory` that knows how to create an Android `View` to draw the actual screen. The easiest way to create a `ViewFactory` is to create a layout runner. A layout runner is a class that has a reference to the view and knows how to update the view given an instance of a screen. In a typical app, every screen will have a layout runner. Layout runners can also work with AndroidX `ViewBinding`s, which we'll use to define the `WelcomeLayoutRunner`. We have a pre-built `WelcomeViewBinding` that you can use. This binding will be autogenerated from layout files in `tutorials-views` when you first build the app. If Android Studio does not automatically find the file, you can manually import it `import workflow.tutorial.views.databinding.WelcomeViewBinding`. However if you would like to create and lay out the view yourself instead, feel free to do so!
96
95
97
96
```kotlin
97
+
@OptIn(WorkflowUiExperimentalApi::class)
98
98
classWelcomeLayoutRunner(
99
99
privatevalwelcomeBinding:WelcomeViewBinding
100
100
) : LayoutRunner<WelcomeScreen> {
@@ -168,6 +168,10 @@ dependencies {
168
168
We'll update the `TutorialActivity` to set its content using a `ViewRegistry` that points to our `LayoutRunner`'s `ViewFactory`:
169
169
170
170
```kotlin
171
+
@file:OptIn(WorkflowUiExperimentalApi::class)
172
+
packageworkflow.tutorial
173
+
// ...
174
+
171
175
// This doesn't look like much right now, but we'll add more layout runners shortly.
0 commit comments