From the course: Android Development: Data Binding

Unlock the full course today

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

Challenge: Color binding adapter

Challenge: Color binding adapter - Android Tutorial

From the course: Android Development: Data Binding

Start my 1-month free trial

Challenge: Color binding adapter

(upbeat music) - [Instructor] All right, let's take what we've learned and do another programming challenge. So for this challenge, we're going to create a binding adapter that's going to change the color of the temperature text based on the temperature value. So here I've started up my finished version of the challenge in the emulator, and we're going to make our code modifications to the existing View Model example. So let's go into the View Model example. And you can see that the temperature starts out at 30 degrees Celsius, and the color of the text here is red. So what I'm going to do is gradually reduce the temperature down. And you can see that when I get down below like 21, it turns into a more orange color. And if I keep on going, then when I get down to below 15, you can see that the temperature text has now turned blue. Okay, so this is the challenge that you're going to build. You're going to need a binding…

Contents