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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.