Nama : Azzura Ferliani Ramadhani
NRP : 5025201190
Kelas : PPB - I
Tahun : 2022
Pada tugas kali ini, kami akan mempelajari tata cara pembuatan project menggunakan Jetpack Compose.
Hasil Preview Project
Source code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.myapplication | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.material3.MaterialTheme | |
import androidx.compose.material3.Surface | |
import androidx.compose.material3.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.tooling.preview.Preview | |
import com.example.myapplication.ui.theme.MyApplicationTheme | |
class MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
MyApplicationTheme { | |
// A surface container using the 'background' color from the theme | |
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) { | |
Greeting("Android") | |
} | |
} | |
} | |
} | |
} | |
@Composable | |
fun Greeting(name: String, modifier: Modifier = Modifier) { | |
Text( | |
text = "Hello $name!", | |
modifier = modifier | |
) | |
} | |
@Preview(showBackground = true) | |
@Composable | |
fun GreetingPreview() { | |
MyApplicationTheme { | |
Greeting("Azzura") | |
} | |
} |
Komentar
Posting Komentar