android4-9 Exercise 2: ComposeView in a Views Activity
===================================================
1. New Project > an Empty Views Activity template (see Android Studio 2: The New UI 3 for the wizard).
2. Open res/layout/activity_main.xml and add the ComposeView element:
3. In MainActivity (after setContentView):
// In the Activity (a ComponentActivity or AppCompatActivity)
setContentView(R.layout.activity_main)
findViewById(R.id.compose_view).setContent {
ComposeHelloTheme {
Greeting("from Compose")
}
}
4. The project may need Compose enabled in app/build.gradle.kts (buildFeatures { compose = true }) and the Compose dependencies and plugin, because a Views template does not
include them (general knowledge; not checked). Add what the IDE and the docs' "Add Compose to a View-based app" codelab list, then sync.
Expected: the greeting appears inside the layout. Report the template's actual contents and anything you had to change. Code unrun.