From the course: Android Development Essential Training: Your First App with Kotlin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Send an action to a new activity

Send an action to a new activity - Android Tutorial

From the course: Android Development Essential Training: Your First App with Kotlin

Start my 1-month free trial

Send an action to a new activity

- [Narrator] When you load a new activity with an intent, you can share data with the new activity in a number of ways. To demonstrate this, I've rebuilt this application a bit. The main activity is much simpler than before in terms of code, but in its content layout file, I'll jump to that file here, I've added four buttons, each displaying an image. These are using a particular kind of component called an image button. And you can see in the text, that I'm referring to the image that I want to display right down here in the source attribute. The first button has an ID and source of monster01, the second of monster02, and so on. When the user touches or clicks one of these buttons, I want to jump to the detail activity, and display the selected image full screen. Now to respond to those clicks, or touches, I'm going to refer to the ID of the button. I'll start here in the main activities on create function, and I'll choose monster01 from content main. When I choose that ID, I'm…

Contents