Level 1
The Atom (Hello Compose)
Composable Functions
In modern Android, UI is not a separate XML file. It is a Kotlin function annotated with `@Composable`.
📚 Explanation
In Jetpack Compose, UI components are functions annotated with `@Composable`. The `setContent` function replaces the old `setContentView(R.layout.activity_main)` pattern. No XML layouts needed!
Note: Code execution is not available for Android/Kotlin in the browser. Use Android Studio to run and test the app.
// MainActivity.ktimport android.os.Bundleimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.compose.material3.Textimport androidx.compose.runtime.Composableclass MainActivity : ComponentActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)// This is the entry point. No setContentView(R.layout...)setContent {Greeting("Android Developer")}}}// A simple UI component@Composablefun Greeting(name: String) {// Material 3 Text componentText(text = "Hello, $name!")}