1 00:00:00,000 --> 00:00:01,890 Currently this is our forecast list. 2 00:00:01,890 --> 00:00:04,849 It looks okay, but it would be nice if we could show the degree symbol 3 00:00:04,849 --> 00:00:06,460 for these temperature values. 4 00:00:06,460 --> 00:00:08,693 Using this notation is best practice. 5 00:00:08,693 --> 00:00:11,646 It will help the translator know how to reorder the text 6 00:00:11,646 --> 00:00:14,820 and the parameters so that it fits the local language. 7 00:00:14,820 --> 00:00:16,910 Now let's look at how we can use this method 8 00:00:16,910 --> 00:00:19,150 to format temperatures within our app. 9 00:00:19,150 --> 00:00:24,360 Within the string.xml file, we declared the format temperature string resource. 10 00:00:24,360 --> 00:00:26,576 We use XLIFF tags to denote that this is where 11 00:00:26,576 --> 00:00:29,032 the decimal temperature value will go. 12 00:00:29,032 --> 00:00:32,509 This is followed by the unit code character for the degrees symbol. 13 00:00:32,509 --> 00:00:35,320 In the utility class, in the format temperature method, 14 00:00:35,320 --> 00:00:37,170 we can use this string resource. 15 00:00:37,170 --> 00:00:39,940 Remember that in this method, we take in a temperature 16 00:00:39,940 --> 00:00:42,440 and a user's preference for metric or imperial. 17 00:00:42,440 --> 00:00:45,040 Then we return the converted temperature. 18 00:00:45,040 --> 00:00:47,950 We're going to modify this method so that it also returns 19 00:00:47,950 --> 00:00:50,750 the formatted string with a degrees symbol after the value. 20 00:00:50,750 --> 00:00:53,960 In order to do this, we need to pass in a context, 21 00:00:53,960 --> 00:00:57,230 From the context we can get access to the string resource ID 22 00:00:57,230 --> 00:00:58,880 that we declared earlier. 23 00:00:58,880 --> 00:01:02,160 Then we passed in any additional parameters for that string template. 24 00:01:02,160 --> 00:01:06,270 In this case we only have one parameter so we pass in the temperature value. 25 00:01:06,270 --> 00:01:08,840 Then this fully formatted string gets returned to the caller. 26 00:01:08,840 --> 00:01:12,580 This method is used in the forecast list, as well in the detail page. 27 00:01:12,580 --> 00:01:14,560 So we also have to update the code there 28 00:01:14,560 --> 00:01:17,300 so that it would compile with this new parameter. 29 00:01:17,300 --> 00:01:19,760 And this is what the app looks like after the change. 30 00:01:19,760 --> 00:01:22,900 Go ahead and make the change in your code to add a string resource 31 00:01:22,900 --> 00:01:24,690 for displaying temperature in degrees. 32 00:01:24,690 --> 00:01:26,630 Check this box when you're done. 33 00:01:26,630 --> 00:01:28,336 And remember, use this notation 34 00:01:28,336 --> 00:01:32,896 going forward, for when you need to format strings.