Connecting activities

As you remember, other than MainActivity, we also have some more activities. In our application, we created activities to create/edit Notes and TODOs. Our plan is to connect them to the button click events, and then, when the user clicks on the button, the proper screen will open. We will start by defining an enum that represents an operation that we will perform in an opened activity. When we open it, we can view, create, or update Note or Todo. Create a new package called model and enum with the name MODE. Make sure you have the following enum values:

 enum class MODE(val mode: Int) { CREATE(0), EDIT(1), VIEW(2); companion object { val EXTRAS_KEY = "MODE" fun getByValue(value: Int): MODE { values().forEach { item -> ...

Get Mastering Android Development with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.