1 00:00:00,670 --> 00:00:05,527 Back in the ColorWheel class, let's change getColor to return an int, 2 00:00:05,527 --> 00:00:06,967 instead of a string. 3 00:00:10,021 --> 00:00:13,890 And now we need to convert the string color to an int. 4 00:00:13,890 --> 00:00:18,789 Right above the return statement, let's add a new int variable named color. 5 00:00:21,263 --> 00:00:27,159 And let's set it equal to Color with a capital C, dot. 6 00:00:27,159 --> 00:00:32,134 And then if we start typing parseColor, we can see that parseColor is a method that 7 00:00:32,134 --> 00:00:37,530 takes in a colorString and returns an int, just what we're looking for. 8 00:00:37,530 --> 00:00:40,050 Hit Enter to select it and add a semicolon. 9 00:00:41,160 --> 00:00:46,410 The parseColor method is a handy utility method that takes a hexadecimal string, 10 00:00:46,410 --> 00:00:48,420 just like we have up here, and 11 00:00:48,420 --> 00:00:53,350 converts it to an integer representation that Android can understand. 12 00:00:53,350 --> 00:00:56,506 So instead of returning a randomly selected color string, 13 00:00:56,506 --> 00:01:00,050 let's pass that random color string into the parseColor method. 14 00:01:06,841 --> 00:01:10,428 Finally, since we need to be returning an integer, 15 00:01:10,428 --> 00:01:15,490 let's return our new color variable and head back to fun facts activity. 16 00:01:17,590 --> 00:01:21,250 Now, instead of a string, we're returning an int. 17 00:01:21,250 --> 00:01:23,495 So color should be an int, not a string. 18 00:01:26,136 --> 00:01:30,584 Looks good, now let's run our app and verify it's working as we expect it to. 19 00:01:33,678 --> 00:01:41,150 Okay, moment of truth, tap the button, and nice, all sorts of different colors. 20 00:01:42,620 --> 00:01:46,510 There's one more thing I'd like to do here, one last color. 21 00:01:46,510 --> 00:01:50,120 Notice that the color of the button text is black, but 22 00:01:50,120 --> 00:01:53,000 in our mock ups, it's matching the background color. 23 00:01:53,000 --> 00:01:54,730 Let's go back to our code and change this. 24 00:01:56,328 --> 00:02:00,310 In the onClick method, we already have the color we want to use. 25 00:02:00,310 --> 00:02:03,940 And we already have a variable for our button, showFactButton. 26 00:02:03,940 --> 00:02:07,800 Let's add a new line at the bottom of onClick and add a reference to our button. 27 00:02:10,080 --> 00:02:12,050 Now let's look for the method we need. 28 00:02:12,050 --> 00:02:17,070 Let's type .set and we're looking for text color. 29 00:02:17,070 --> 00:02:20,940 So let's add text, and then down here, 30 00:02:20,940 --> 00:02:26,330 we see a method called setTextColor that takes on an int parameter. 31 00:02:26,330 --> 00:02:27,060 Let's pick that one. 32 00:02:28,410 --> 00:02:29,920 Then let's pass in our color variable. 33 00:02:31,810 --> 00:02:34,410 And cool, but we're not quite done. 34 00:02:34,410 --> 00:02:38,500 We're only changing the text color after the button has been tapped. 35 00:02:38,500 --> 00:02:42,310 If the button hasn't been tapped, we'll still see black text. 36 00:02:42,310 --> 00:02:45,580 We should change our button's default text color to match the default 37 00:02:45,580 --> 00:02:46,790 background, green. 38 00:02:46,790 --> 00:02:50,430 Let's go back into our activity_fun_facts layout file. 39 00:02:50,430 --> 00:02:51,900 And make sure we're on the Design tab. 40 00:02:53,410 --> 00:02:54,901 Then let's select our relativeLayout. 41 00:02:57,663 --> 00:03:00,160 And copy the green color from the background property. 42 00:03:02,260 --> 00:03:06,981 Then let's select our button, scroll down to the textColor property. 43 00:03:12,273 --> 00:03:18,230 Paste in our color, hit Enter, and there we go, green text. 44 00:03:18,230 --> 00:03:20,127 Now let's run the app to make sure everything works. 45 00:03:24,133 --> 00:03:28,096 Okay, just like we expected, lots of different colors for 46 00:03:28,096 --> 00:03:32,469 the background and lots of different colors for our button text. 47 00:03:32,469 --> 00:03:36,565 All right, that's really coming together. 48 00:03:36,565 --> 00:03:38,459 We're done with all the programming, but 49 00:03:38,459 --> 00:03:41,990 there's still one little thing before we can move on to testing and debugging.