From the course: Android Development Essential Training: 2 User Interface Design

Unlock the full course today

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

Load image resources at runtime

Load image resources at runtime - Android Tutorial

From the course: Android Development Essential Training: 2 User Interface Design

Start my 1-month free trial

Load image resources at runtime

- [Instructor] Currently, we're setting the drawable resource in a static way. Every time we run the app, the image will be the same and it doesn't update. But with the imageView component, we can low resources at runtime as well. This will allow for the image to change, based on either a user action or a change in data. Let's update our layout so that we can include some interaction from the user. For this, we'll introduce a new View that we haven't worked with before, the switch. A switch allows the user to choose between two states. Let's bring over the switch from our pallet, we'll drop it inside of our View. And now we need to update the constraints. We'll constraint the top to the bottom of the imageView, and then the other sides to the parent. The first thing we need to do is remove the bottom constraint from our imageView. We'll click on that constraint handle and then we'll delete it. And it goes all the way…

Contents