Create a Simple Android App

Apr 10 2024 · Kotlin 1.9.21, Android 14, Android Studio Hedgehog | 2023.1.1

Lesson 04: Add Interactivity

Demo

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Now that you can see what you’re typing in the chat input text box, it’s time to do something with that text when you hit the Send button.

Button(onClick = {
    chatOutputText = chatInputText
    chatInputText = ""
  }) {
  Text(text = stringResource(id = R.string.send_button))
}
UserInput(onMessageSent = { content ->
  uiState.addMessage(
    content, null
  )
})
fun addMessage(msg: String, photoUri: Uri?) {
  // TODO : implement :]
}
fun addMessage(msg: String, photoUri: Uri?) {
  val message = Message(text = msg)
  val messageModel = MessageUiModel(message = message, user = meUser)
  _messages.add(messageModel) // Add to the beginning of the list
}
private val meUser = User(id = "me", firstName = "Khaled", lastName = "Abdul Wahab")
See forum comments
Cinema mode Download course materials from Github
Previous: Recomposition Next: Interactivity Quiz