0% found this document useful (0 votes)
7 views1 page

Session 2 Code Android Studio

This document contains a Kotlin code for an Android application that displays a greeting card. It defines a MainActivity that sets up a greeting message using Jetpack Compose, with a customizable name and a cyan background. The app also includes a preview function to visualize the greeting card layout.

Uploaded by

1dt22cs059
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Session 2 Code Android Studio

This document contains a Kotlin code for an Android application that displays a greeting card. It defines a MainActivity that sets up a greeting message using Jetpack Compose, with a customizable name and a cyan background. The app also includes a preview function to visualize the greeting card layout.

Uploaded by

1dt22cs059
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

package [Link].

greetingcard

import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]

class MainActivity : ComponentActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
[Link](savedInstanceState)
enableEdgeToEdge()
setContent {
GreetingCardTheme {
Scaffold(modifier = [Link]()) { innerPadding
->
Greeting(
name = "Hemanth",
modifier = [Link](innerPadding)
)
}
}
}
}
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Surface(color = [Link]) {
Text(
text = "Hi, my name is $name!",
modifier = [Link]([Link])
)
}
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
GreetingCardTheme {
Greeting("Hemanth")
}
}

You might also like