Your First Kotlin Android App: An App From Scratch

Aug 15 2023 · Kotlin 1.8.20, Android 13, Android Studio Flamingo | 2022.2.1

Part 2: Manage Data in Jetpack Compose

16. Work with Strings

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 15. Learn About State Hoisting Next episode: 17. Challenge: Create a Custom Composable

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

It’s time to tackle the next item on our programming to-do list: “Read the value of the slider after the user presses the Hit Me button.” But before you do that, I want to tell you about a very important data type you’ll use in your Android apps: “Strings”. You’ve already used this when working with the Text composable but let’s go a bit further.

text = { Text("The slider's value is $sliderValue") }
fun ResultDialog(
  hideDialog: () -> Unit,
  sliderValue: Int, // New Code
  modifier: Modifier = Modifier
) {
val sliderToInt = (sliderValue * 100).toInt()
  hideDialog = { alertIsVisible = false },
  sliderValue = sliderToInt // New Code
text = { Text(stringResource(id = R.string.result_dialog_message)) }
//    text = { Text("The slider's value is $sliderValue") }
<string name="result_dialog_message">The slider\'s value is %1$d.</string>
text = { Text(stringResource(id = R.string.result_dialog_message, sliderValue)) }
var alertIsVisible by rememberSaveable { mutableStateOf(false) }
var sliderValue by rememberSaveable { mutableStateOf(0.5f) }