Kotlin Enums Tutorial for Android: Getting Started

In this tutorial, you’ll build an Android app, using the full potential of Kotlin Enums to handle a list of cartoon avatars and help your users easily create their profiles. By Caio Fukelmann Landau.

Leave a rating/review
Download materials
Save for later
Share
You are currently viewing page 4 of 4 of this article. Click here to view the first page.

Where to Go From Here?

Download the final project using the Download Materials button at the top or bottom of this tutorial.

In this tutorial, you learned:

  • What enums are and how to use them when you need a predefined set of constants
  • How ART and R8 helped reduce the performance hit that used to be a problem with enums in the past
  • How to use when() for flow control using enums
  • Why exhaustive code matters and how enums help with this
  • How to add extra data to enum constants
  • How every enum in Kotlin implements equality automatically
  • The use of name to pass enum cases via Intent
  • How to add methods to enums

To learn even more about enums and their functionality, check out the Kotlin and Android: Beyond the Basics with Sealed Classes tutorial.

We hope you enjoyed this tutorial. If you have any questions or comments, please join the forum discussion below!