1 00:00:04,740 --> 00:00:06,870 Now that we've got the database set up 2 00:00:06,870 --> 00:00:09,719 to store an updateTask records, it's now 3 00:00:09,719 --> 00:00:11,940 time to write the code so that we can 4 00:00:11,940 --> 00:00:15,029 add new details and list the tasks. Now 5 00:00:15,029 --> 00:00:16,410 to do that we're going to need a user 6 00:00:16,410 --> 00:00:18,330 interface, so we're going to start in 7 00:00:18,330 --> 00:00:20,820 this video by creating the menu that 8 00:00:20,820 --> 00:00:22,530 we'll be using to perform the various 9 00:00:22,530 --> 00:00:24,660 functions in our app. So I'm going to add 10 00:00:24,660 --> 00:00:26,789 all the menu items in this video, rather 11 00:00:26,789 --> 00:00:28,140 than jumping in and out of the menu 12 00:00:28,140 --> 00:00:30,060 editor, and then we'll add the code for 13 00:00:30,060 --> 00:00:32,340 each item as we need it in future videos. 14 00:00:32,340 --> 00:00:34,680 Alright so we will start by going into 15 00:00:34,680 --> 00:00:38,010 our res folder, into our menu subfolder, 16 00:00:38,010 --> 00:00:40,730 and double-clicking menu_main.xml. 17 00:00:40,730 --> 00:00:44,010 That's going to open up the menu 18 00:00:44,010 --> 00:00:46,170 for our application, and I'm going to 19 00:00:46,170 --> 00:00:47,640 close the project pane just to make a 20 00:00:47,640 --> 00:00:49,890 bit more space, so that we'll be able to 21 00:00:49,890 --> 00:00:51,329 see the attributes as well. It's going to 22 00:00:51,329 --> 00:00:53,640 expand that out a little bit, and what we 23 00:00:53,640 --> 00:00:55,079 want to do is, we want to start by 24 00:00:55,079 --> 00:00:58,469 dragging another four menu item widgets 25 00:00:58,469 --> 00:01:00,960 onto the layout. Mow personally, I find it 26 00:01:00,960 --> 00:01:03,149 easier to drop them onto the component 27 00:01:03,149 --> 00:01:05,159 tree than watching the guides to make 28 00:01:05,159 --> 00:01:07,170 sure they go where I want. But it can be 29 00:01:07,170 --> 00:01:09,960 hard to use the guides if the component 30 00:01:09,960 --> 00:01:11,520 tree isn't wide enough, and that's 31 00:01:11,520 --> 00:01:13,470 because it scrolls sideways, making it 32 00:01:13,470 --> 00:01:14,909 hard to get things where you want them. 33 00:01:14,909 --> 00:01:16,860 But again, it can be a good idea to close 34 00:01:16,860 --> 00:01:18,780 down the project pane and make the 35 00:01:18,780 --> 00:01:21,060 component tree wider as necessary. So I'm 36 00:01:21,060 --> 00:01:23,130 going to place two menu items above the 37 00:01:23,130 --> 00:01:25,740 existing settings item and two below, so 38 00:01:25,740 --> 00:01:28,260 that we've got five in total. So I'm going to come 39 00:01:28,260 --> 00:01:29,670 up here to the menu item and drag the 40 00:01:29,670 --> 00:01:33,509 first one, and notice how it scrolled 41 00:01:33,509 --> 00:01:34,680 sideways in, so I'm gonna make it a 42 00:01:34,680 --> 00:01:36,090 little bit wider to see whether we can 43 00:01:36,090 --> 00:01:37,890 avoid that happening again. I'll grab the 44 00:01:37,890 --> 00:01:39,479 second one, and again I'm putting that 45 00:01:39,479 --> 00:01:42,570 above the current settings, and I'm going 46 00:01:42,570 --> 00:01:44,759 to add two below the action_settings as 47 00:01:44,759 --> 00:01:49,799 well. Okay so there's our five as you 48 00:01:49,799 --> 00:01:50,880 can see there, and I'll just move this back 49 00:01:50,880 --> 00:01:53,939 to the left a bit so that we can increase the 50 00:01:53,939 --> 00:01:57,930 size of this menu a little bit. Now 51 00:01:57,930 --> 00:02:00,210 obviously we're altering a menu that was 52 00:02:00,210 --> 00:02:02,040 created from the Android Studio template, 53 00:02:02,040 --> 00:02:04,020 and the settings menu item was already 54 00:02:04,020 --> 00:02:06,180 present, as you saw there. Now you may get 55 00:02:06,180 --> 00:02:08,459 a strange effect, where the ordering 56 00:02:08,459 --> 00:02:10,679 looks correct in the component tree but 57 00:02:10,679 --> 00:02:12,269 settings still appear at the end of the 58 00:02:12,269 --> 00:02:14,189 list in the designer. And you can see in 59 00:02:14,189 --> 00:02:15,480 my case I've got a similar thing. I've 60 00:02:15,480 --> 00:02:16,859 got Settings appearing down the bottom 61 00:02:16,859 --> 00:02:17,840 here, and the 62 00:02:17,840 --> 00:02:19,010 four items I added, even though you 63 00:02:19,010 --> 00:02:20,989 saw me drag them into the correct place 64 00:02:20,989 --> 00:02:22,069 in the component tree - 65 00:02:22,069 --> 00:02:23,900 and in fact the component tree is showing 66 00:02:23,900 --> 00:02:25,730 that - they're actually visually showing 67 00:02:25,730 --> 00:02:27,860 in the wrong place. Now this isn't a bug - 68 00:02:27,860 --> 00:02:30,470 it's because of an attribute that the 69 00:02:30,470 --> 00:02:32,569 template sets. So if we select the 70 00:02:32,569 --> 00:02:35,360 settings, the action_settings here, the 71 00:02:35,360 --> 00:02:37,610 Settings menu item, then we go into our 72 00:02:37,610 --> 00:02:41,840 extended attributes - we can see this - and 73 00:02:41,840 --> 00:02:43,879 notice over here the orderinCategory. 74 00:02:43,879 --> 00:02:45,920 So the template may have given this a 75 00:02:45,920 --> 00:02:48,709 value of 100, as it has in my case. If it 76 00:02:48,709 --> 00:02:50,900 hasn't for you though, enter 100 for this 77 00:02:50,900 --> 00:02:53,480 orderinCategory attribute. When you do 78 00:02:53,480 --> 00:02:54,950 that you'll see that Settings know goes to 79 00:02:54,950 --> 00:02:56,510 the end of the list as it's currently 80 00:02:56,510 --> 00:02:58,790 showing for me. So that orderin 81 00:02:58,790 --> 00:03:01,610 Categorys attribute's used to order the 82 00:03:01,610 --> 00:03:03,950 menu items. Now it can be useful if 83 00:03:03,950 --> 00:03:06,290 you're adding items in code. You can use 84 00:03:06,290 --> 00:03:08,720 that attribute to make sure the menu 85 00:03:08,720 --> 00:03:10,310 item appears in the order that you 86 00:03:10,310 --> 00:03:12,230 want in to. But we've actually put them in 87 00:03:12,230 --> 00:03:14,299 the right order, so consequently we can 88 00:03:14,299 --> 00:03:16,910 delete the value for orderinCategory 89 00:03:16,910 --> 00:03:18,920 for our settings menu item. So I'm going 90 00:03:18,920 --> 00:03:21,859 to go ahead and do that, press ENTER. And 91 00:03:21,859 --> 00:03:23,000 you can see now that I've done that, 92 00:03:23,000 --> 00:03:25,040 all our items are defaulting to 93 00:03:25,040 --> 00:03:27,019 zero and because they all have the same 94 00:03:27,019 --> 00:03:30,170 value, the items, the menu items, will 95 00:03:30,170 --> 00:03:32,150 actually appear in the order we've got 96 00:03:32,150 --> 00:03:33,530 them in the layout - the order that we've 97 00:03:33,530 --> 00:03:34,730 added them in the component tree. 98 00:03:34,730 --> 00:03:37,010 Now I had problems with the order 99 00:03:37,010 --> 00:03:39,769 changing after reformatting the xml, so 100 00:03:39,769 --> 00:03:42,139 it's a good idea to be explicit. So as 101 00:03:42,139 --> 00:03:43,340 such we're going to give each of our 102 00:03:43,340 --> 00:03:46,549 items an orderinCategory value. Now 103 00:03:46,549 --> 00:03:47,810 we're going to start off using our first 104 00:03:47,810 --> 00:03:50,239 menu item to add a new task, so I'm 105 00:03:50,239 --> 00:03:52,849 going to click on that top menu item. I'm 106 00:03:52,849 --> 00:03:55,250 going to come over here and under ID, I'm 107 00:03:55,250 --> 00:03:56,870 going to give it a new ID, and we'll call 108 00:03:56,870 --> 00:04:01,329 this one menumain_addTask. 109 00:04:01,329 --> 00:04:03,230 We're going to create a new string 110 00:04:03,230 --> 00:04:07,940 resource for the title, and for the 111 00:04:07,940 --> 00:04:09,769 resource name we're going to go with 112 00:04:09,769 --> 00:04:14,120 menutitle_addTask, and 113 00:04:14,120 --> 00:04:17,298 for the resource value we'll go with 114 00:04:17,298 --> 00:04:21,048 addTask. Now for the icon we'll use the 115 00:04:21,048 --> 00:04:23,090 standard Android icon for adding a new 116 00:04:23,090 --> 00:04:25,550 record. So I want to click on the 117 00:04:25,550 --> 00:04:27,800 ellipsis over here to the right of the 118 00:04:27,800 --> 00:04:30,469 icon attribute. You want to make sure that 119 00:04:30,469 --> 00:04:31,610 driver was 120 00:04:31,610 --> 00:04:33,590 selected as it is for me, and then we want to 121 00:04:33,590 --> 00:04:36,770 do a search there for ic_menu 122 00:04:36,770 --> 00:04:38,000 _add. 123 00:04:38,000 --> 00:04:39,710 And notice when I do that it's popped up 124 00:04:39,710 --> 00:04:41,509 over here on the right hand side, and I 125 00:04:41,509 --> 00:04:43,909 can just click on OK. We've now added 126 00:04:43,909 --> 00:04:47,389 that icon to our menu item. Now in terms 127 00:04:47,389 --> 00:04:49,819 of the showAsAction, we're going to 128 00:04:49,819 --> 00:04:51,740 expand that, and what we're going to use 129 00:04:51,740 --> 00:04:54,349 there is, we'll use ifRoom. So I'll click on 130 00:04:54,349 --> 00:04:57,500 that, noting that when I did that the 131 00:04:57,500 --> 00:05:00,500 icon appeared up in the toolbar, appeared 132 00:05:00,500 --> 00:05:02,599 over here in the toolbar, which is 133 00:05:02,599 --> 00:05:04,819 correct. The other thing we are going to 134 00:05:04,819 --> 00:05:08,029 do is set our orderinCategory to 10. We'll come 135 00:05:08,029 --> 00:05:10,219 over here and click on that, 10, press 136 00:05:10,219 --> 00:05:13,069 Enter. Now don't worry if it jumps around 137 00:05:13,069 --> 00:05:15,529 in the display or disappears, or anything 138 00:05:15,529 --> 00:05:16,400 of that nature. 139 00:05:16,400 --> 00:05:18,139 It'll come right once we've set that 140 00:05:18,139 --> 00:05:19,909 attribute for all five of our menu 141 00:05:19,909 --> 00:05:22,069 items. Let's, for now, move on to the next 142 00:05:22,069 --> 00:05:23,689 item, clicking on that in the component 143 00:05:23,689 --> 00:05:26,419 tree, and this one is going to be used to 144 00:05:26,419 --> 00:05:29,000 show our Durations Report. So I'm going 145 00:05:29,000 --> 00:05:30,949 to go with an ID for this one, for 146 00:05:30,949 --> 00:05:35,569 menumain_showDurations, 147 00:05:35,569 --> 00:05:39,500 and the title, we'll create a string 148 00:05:39,500 --> 00:05:43,789 resource. The resource name we're going to 149 00:05:43,789 --> 00:05:46,520 go with is menutitle_show 150 00:05:46,520 --> 00:05:49,610 Durations. That's menu items, 151 00:05:49,610 --> 00:05:53,110 sorry menutitle_showDurations. And 152 00:05:53,110 --> 00:05:56,180 the actual text - the resource value - we'll 153 00:05:56,180 --> 00:05:59,360 go with Durations Report and press ENTER 154 00:05:59,360 --> 00:06:02,000 there. Now you're probably starting to detect 155 00:06:02,000 --> 00:06:03,949 a pattern in these IDs and resource 156 00:06:03,949 --> 00:06:06,169 names. It doesn't really matter what you 157 00:06:06,169 --> 00:06:08,629 call them, but using a standard prefix 158 00:06:08,629 --> 00:06:11,210 like I have here, it's a lot easy to find 159 00:06:11,210 --> 00:06:12,469 them if you have to look for them in the 160 00:06:12,469 --> 00:06:14,810 string resources file. Now we're going 161 00:06:14,810 --> 00:06:16,580 to have more than one menu, and that's 162 00:06:16,580 --> 00:06:18,560 why I've started the IDs for this menu 163 00:06:18,560 --> 00:06:20,689 with menu main so that we don't get 164 00:06:20,689 --> 00:06:23,000 confused about which menu we're dealing 165 00:06:23,000 --> 00:06:25,969 with later. Alright, so in terms of the icon 166 00:06:25,969 --> 00:06:28,099 for our Durations Report, I'm going to 167 00:06:28,099 --> 00:06:30,620 click on the ellipsis over here. I'm 168 00:06:30,620 --> 00:06:33,889 going to do, we're going to use the ic 169 00:06:33,889 --> 00:06:38,240 _menu_view. You can see that's 170 00:06:38,240 --> 00:06:40,940 popped up there, click on OK. We're also 171 00:06:40,940 --> 00:06:42,830 going to click on the showAsAction 172 00:06:42,830 --> 00:06:44,300 attribute. We're going to click on if 173 00:06:44,300 --> 00:06:45,140 Room 174 00:06:45,140 --> 00:06:46,550 so that it will appear in the toolbar if 175 00:06:46,550 --> 00:06:48,220 there's enough room for it to appear, 176 00:06:48,220 --> 00:06:50,780 and we're going to change the orderinCategory 177 00:06:50,780 --> 00:06:52,750 to 20 for this one. 178 00:06:52,750 --> 00:06:55,850 Now don't worry too much here if the 179 00:06:55,850 --> 00:06:57,560 item doesn't move up in the toolbar. 180 00:06:57,560 --> 00:06:59,480 that's how the ifRoom setting works. 181 00:06:59,480 --> 00:07:01,370 The preview though, doesn't always 182 00:07:01,370 --> 00:07:03,560 work correctly, displaying icons in the 183 00:07:03,560 --> 00:07:05,390 toolbar even if you rotate into 184 00:07:05,390 --> 00:07:07,550 landscape, but it will work when we run 185 00:07:07,550 --> 00:07:09,560 the app. Alright so moving on now. The 186 00:07:09,560 --> 00:07:11,420 third menu item's already set to 187 00:07:11,420 --> 00:07:13,160 settings, so I'm going to click on that 188 00:07:13,160 --> 00:07:16,010 anyway, and you can see there that the ID 189 00:07:16,010 --> 00:07:18,650 doesn't fit our naming pattern. Now 190 00:07:18,650 --> 00:07:20,510 whether you decide to change the ID or 191 00:07:20,510 --> 00:07:22,820 not really depends, to some extent, on the 192 00:07:22,820 --> 00:07:25,220 structure of your app. In this app the 193 00:07:25,220 --> 00:07:26,990 settings option will only appear on this 194 00:07:26,990 --> 00:07:29,510 menu, so I'm going to change the ID to 195 00:07:29,510 --> 00:07:31,700 keep it consistent. Now you may write an 196 00:07:31,700 --> 00:07:33,500 app where the settings option appears on 197 00:07:33,500 --> 00:07:36,560 all menus. In that case, setting the ID to 198 00:07:36,560 --> 00:07:38,660 start with menu main wouldn't make sense. 199 00:07:38,660 --> 00:07:40,700 In that scenario it would probably make 200 00:07:40,700 --> 00:07:42,770 more sense to leave it as it is. Now 201 00:07:42,770 --> 00:07:44,480 it'll be different to all the other menu 202 00:07:44,480 --> 00:07:46,790 item IDs, but that will emphasize the 203 00:07:46,790 --> 00:07:48,680 fact that it appears on more than one 204 00:07:48,680 --> 00:07:50,930 menu. But in this particular example for 205 00:07:50,930 --> 00:07:53,240 this app, I'm going to change the ID to 206 00:07:53,240 --> 00:07:55,250 menumain_settings because 207 00:07:55,250 --> 00:07:56,750 it's only going to appear in this menu. 208 00:07:56,750 --> 00:07:58,490 So I'm going to go in there and make that change. 209 00:07:58,490 --> 00:08:05,060 So it's going to be menumain underscore 210 00:08:05,060 --> 00:08:08,150 settings. I'm going to create a new 211 00:08:08,150 --> 00:08:14,120 string resource - the title - and we'll go 212 00:08:14,120 --> 00:08:18,320 with menutitle_settings, and 213 00:08:18,320 --> 00:08:20,210 for the resource value we'll go with the 214 00:08:20,210 --> 00:08:23,000 word settings. Now we're not going to use 215 00:08:23,000 --> 00:08:25,250 an icon for this option, and therefore 216 00:08:25,250 --> 00:08:27,410 we're going to set the showAsAction. I'm 217 00:08:27,410 --> 00:08:28,520 going to set that to never, which it's 218 00:08:28,520 --> 00:08:31,130 currently selected to. Now that doesn't 219 00:08:31,130 --> 00:08:33,260 mean though, that it's never shown. What it 220 00:08:33,260 --> 00:08:34,789 means is that it won't appear in the 221 00:08:34,789 --> 00:08:37,309 toolbar, and the user will have to expand 222 00:08:37,309 --> 00:08:39,620 the menu to find it, which is fine in our 223 00:08:39,620 --> 00:08:41,299 scenario. And I'm going to finish by 224 00:08:41,299 --> 00:08:43,970 setting the orderinCategory, because 225 00:08:43,970 --> 00:08:45,020 it's the third entry and we're 226 00:08:45,020 --> 00:08:49,340 incrementing in tens to 30. Alright, so 227 00:08:49,340 --> 00:08:51,200 the fourth menu item now, second to last 228 00:08:51,200 --> 00:08:53,180 one, this is going to show an About 229 00:08:53,180 --> 00:08:54,950 screen. So I'm going to select that in 230 00:08:54,950 --> 00:08:57,110 the component tree, and we're going to go 231 00:08:57,110 --> 00:08:58,820 with the ID 232 00:08:58,820 --> 00:09:03,970 menumain_showAbout. 233 00:09:03,970 --> 00:09:06,880 We're going to create a string resource, 234 00:09:06,880 --> 00:09:11,270 and we'll go with menutitle underscore 235 00:09:11,270 --> 00:09:15,380 showAbout, and the resource value, we're 236 00:09:15,380 --> 00:09:18,260 going to type it in as taskTimer, About 237 00:09:18,260 --> 00:09:21,410 TaskTimer. We're going to select an 238 00:09:21,410 --> 00:09:22,940 icon for this one - I'll use the ellipsis - 239 00:09:22,940 --> 00:09:26,000 and there's a good icon we can use here 240 00:09:26,000 --> 00:09:29,390 called ic_menu 241 00:09:29,390 --> 00:09:31,010 underscore info, that's underscore 242 00:09:31,010 --> 00:09:32,810 details. I'm going to use that and click 243 00:09:32,810 --> 00:09:36,020 on OK. In terms of the showAsAction 244 00:09:36,020 --> 00:09:37,790 attribute, we're going to set that also 245 00:09:37,790 --> 00:09:40,310 to ifRoom, and then we'll finish off by 246 00:09:40,310 --> 00:09:45,830 setting the orderinCategory to 40. Al 247 00:09:45,830 --> 00:09:47,270 right so that brings us now to the last 248 00:09:47,270 --> 00:09:49,400 item. Now this one's a little bit 249 00:09:49,400 --> 00:09:51,500 different and that's because the users 250 00:09:51,500 --> 00:09:53,480 of this app will never see it. So let's 251 00:09:53,480 --> 00:09:54,800 set it up and then I'll explain what 252 00:09:54,800 --> 00:09:56,690 it's for. So I'm going to select it over 253 00:09:56,690 --> 00:09:58,940 here in the component tree. For the ID 254 00:09:58,940 --> 00:10:01,030 we're going to go with menumain 255 00:10:01,030 --> 00:10:06,380 underscore generate, and for the title, we'll 256 00:10:06,380 --> 00:10:09,200 create a string resource again, menu 257 00:10:09,200 --> 00:10:13,130 title_generate, and the 258 00:10:13,130 --> 00:10:16,340 resource value will be Generate data. 259 00:10:16,340 --> 00:10:18,860 Press enter there. Now we're not going to 260 00:10:18,860 --> 00:10:20,990 have an icon for this option either, and 261 00:10:20,990 --> 00:10:22,280 it'll only appear when the main's 262 00:10:22,280 --> 00:10:24,290 expanded. So therefore we're going to set 263 00:10:24,290 --> 00:10:27,260 the showAsAction to never, making sure 264 00:10:27,260 --> 00:10:29,360 that that's checked, which it is now, and 265 00:10:29,360 --> 00:10:33,460 I'm going to set the orderinCategory to 50. 266 00:10:33,460 --> 00:10:35,390 Now the other thing we're going to do 267 00:10:35,390 --> 00:10:37,430 here for this particular item, is we're 268 00:10:37,430 --> 00:10:39,500 going to set its visible property. We 269 00:10:39,500 --> 00:10:41,240 don't normally want this item to appear 270 00:10:41,240 --> 00:10:42,980 in the menu, so we're going to set it to 271 00:10:42,980 --> 00:10:45,500 an invisible, while making sure down here 272 00:10:45,500 --> 00:10:48,080 that the tri-state visible property is 273 00:10:48,080 --> 00:10:51,200 unchecked, like so. Notice that it disappeared 274 00:10:51,200 --> 00:10:53,660 from the menu when I did that. And just 275 00:10:53,660 --> 00:10:55,150 out of interest if I click it again, 276 00:10:55,150 --> 00:10:58,490 that's enabled. Click it to two, make it 277 00:10:58,490 --> 00:11:00,950 disabled, and basically if you click it 278 00:11:00,950 --> 00:11:02,990 again this little dash there, that means 279 00:11:02,990 --> 00:11:04,580 the setting will use its default value, 280 00:11:04,580 --> 00:11:06,950 which at the moment is visible for this 281 00:11:06,950 --> 00:11:08,810 property. So in our case we don't want 282 00:11:08,810 --> 00:11:10,640 it to be visible. I'm checking it again, 283 00:11:10,640 --> 00:11:12,620 and checking it until it's 284 00:11:12,620 --> 00:11:14,630 actually unchecked and it disappears from the 285 00:11:14,630 --> 00:11:17,240 menu. So basically, here a tick means visible 286 00:11:17,240 --> 00:11:18,830 and not having a tick means it's 287 00:11:18,830 --> 00:11:21,290 invisible. And if we have a quick look at 288 00:11:21,290 --> 00:11:24,560 the xml, we can see that Android visible 289 00:11:24,560 --> 00:11:26,810 is now set to false down here, for our 290 00:11:26,810 --> 00:11:30,050 mainmenu_generate. Now when 291 00:11:30,050 --> 00:11:31,580 you're using a database in your app you'll 292 00:11:31,580 --> 00:11:33,740 need to test it with some test data. 293 00:11:33,740 --> 00:11:35,450 Now typing all that in can be very 294 00:11:35,450 --> 00:11:37,790 time-consuming, so we'll be creating a 295 00:11:37,790 --> 00:11:39,920 class to generate a load of random test 296 00:11:39,920 --> 00:11:42,800 data a bit later in this section. Once 297 00:11:42,800 --> 00:11:44,720 we've written that class we'll add some 298 00:11:44,720 --> 00:11:46,790 code to enable this option, so that we 299 00:11:46,790 --> 00:11:48,620 can generate thousands of test timings 300 00:11:48,620 --> 00:11:50,420 just to make sure that the reports work 301 00:11:50,420 --> 00:11:52,940 okay. Alright, so at this point that's the 302 00:11:52,940 --> 00:11:54,710 main menu complete, but there is actually 303 00:11:54,710 --> 00:11:56,540 a problem with it. Now we've seen this 304 00:11:56,540 --> 00:11:58,310 before in earlier apps so you may 305 00:11:58,310 --> 00:12:00,290 remember what it is. What we didn't do 306 00:12:00,290 --> 00:12:02,360 earlier was run the app without fixing 307 00:12:02,360 --> 00:12:04,250 the issue, so I'm going to leave it until 308 00:12:04,250 --> 00:12:05,990 we've seen what happens when we don't 309 00:12:05,990 --> 00:12:08,330 fix it. Now before we can run the app we 310 00:12:08,330 --> 00:12:10,070 need to fix an error, though, in Main 311 00:12:10,070 --> 00:12:12,100 Activity. So I'm going to bring back the 312 00:12:12,100 --> 00:12:15,730 project pane and then open MainActivity. 313 00:12:15,730 --> 00:12:18,110 So you may not actually see an error 314 00:12:18,110 --> 00:12:20,690 here straight away, so you may need to 315 00:12:20,690 --> 00:12:22,760 Build - in my case I have to do that - and 316 00:12:22,760 --> 00:12:24,500 select Build and rebuild the project, 317 00:12:24,500 --> 00:12:26,540 and it should pop up after we've done 318 00:12:26,540 --> 00:12:28,580 that. And you can see that we've got an error 319 00:12:28,580 --> 00:12:29,990 here, and if we scroll down to the bottom 320 00:12:29,990 --> 00:12:32,660 and have a look, 321 00:12:32,660 --> 00:12:35,810 the error's in the onOptionsItemSelected 322 00:12:35,810 --> 00:12:37,759 function, and that's because we changed 323 00:12:37,759 --> 00:12:40,190 the ID action_settings for 324 00:12:40,190 --> 00:12:41,600 the Settings menu item. 325 00:12:41,600 --> 00:12:44,000 So we'll correct that now - that should be 326 00:12:44,000 --> 00:12:47,079 called menumain_settings. 327 00:12:47,079 --> 00:12:49,670 Once you've corrected that we can now 328 00:12:49,670 --> 00:12:51,529 run the app and see our menus. Let's go 329 00:12:51,529 --> 00:12:59,300 ahead and do that. Now you can see here 330 00:12:59,300 --> 00:13:01,790 that the menu's appearing okay for me, but 331 00:13:01,790 --> 00:13:03,379 you may not have any icons on the 332 00:13:03,379 --> 00:13:05,449 toolbar. You might have to expand the 333 00:13:05,449 --> 00:13:10,310 menu up here to see any options. Now there's 334 00:13:10,310 --> 00:13:12,110 clearly enough room over here in the 335 00:13:12,110 --> 00:13:13,939 toolbar, so you might be wondering why 336 00:13:13,939 --> 00:13:15,800 aren't the icons showing? And again, 337 00:13:15,800 --> 00:13:17,810 that's something that may be popping up 338 00:13:17,810 --> 00:13:20,029 for you, but in my case that's not doing 339 00:13:20,029 --> 00:13:21,980 it - it's actually working fine. The reason 340 00:13:21,980 --> 00:13:23,720 for this problem was that some versions 341 00:13:23,720 --> 00:13:26,870 of Android Studio incorrectly used the 342 00:13:26,870 --> 00:13:29,269 Android name space for the showAsAction 343 00:13:29,269 --> 00:13:31,100 property. Now we've used the 344 00:13:31,100 --> 00:13:33,439 compatibility library so the name space 345 00:13:33,439 --> 00:13:36,560 should be app. Now if that happens and it 346 00:13:36,560 --> 00:13:38,000 hasn't happened here - you can see it does 347 00:13:38,000 --> 00:13:39,980 seem to have been fixed now - then we have 348 00:13:39,980 --> 00:13:42,170 to edit the menu_main.xml 349 00:13:42,170 --> 00:13:45,079 manually to fix that up. So if that does 350 00:13:45,079 --> 00:13:47,060 happen for you, all the incorrect 351 00:13:47,060 --> 00:13:49,089 properties will be highlighted in that 352 00:13:49,089 --> 00:13:52,130 xml file. Android Studio knows they're 353 00:13:52,130 --> 00:13:54,079 wrong, and when you hover the mouse over 354 00:13:54,079 --> 00:13:55,790 one or more of the underlined properties, 355 00:13:55,790 --> 00:13:57,199 it actually tells you what you should 356 00:13:57,199 --> 00:13:59,899 use at column showAsAction with the 357 00:13:59,899 --> 00:14:02,089 AppCompat library. Now if we just briefly 358 00:14:02,089 --> 00:14:05,300 go back to our menu_main.xml, 359 00:14:05,300 --> 00:14:08,410 then I go into text, you can see in my case 360 00:14:08,410 --> 00:14:12,410 I've got app showAsAction set for each 361 00:14:12,410 --> 00:14:14,149 one of these menu options and I haven't got 362 00:14:14,149 --> 00:14:16,519 that problem. So it does look like Google 363 00:14:16,519 --> 00:14:17,959 have actually fixed the issue which is 364 00:14:17,959 --> 00:14:24,110 good. Alright I'm going to take this opportunity 365 00:14:24,110 --> 00:14:30,290 just to reformat the XML. So you want to 366 00:14:30,290 --> 00:14:32,059 make sure that your menu items appear in 367 00:14:32,059 --> 00:14:34,040 the same order as mine, if you didn't 368 00:14:34,040 --> 00:14:35,329 want to test your code and check your 369 00:14:35,329 --> 00:14:36,589 code down the track to make sure it's 370 00:14:36,589 --> 00:14:38,449 the same. Alright so getting back to our 371 00:14:38,449 --> 00:14:39,920 app again. We haven't restarted - it's 372 00:14:39,920 --> 00:14:41,059 still running in the background there. 373 00:14:41,059 --> 00:14:42,860 Notice that there's no room at the 374 00:14:42,860 --> 00:14:44,839 moment for the About icon to appear, and 375 00:14:44,839 --> 00:14:46,520 it appears as a menu selection 376 00:14:46,520 --> 00:14:49,640 there. But if I change this into landscape 377 00:14:49,640 --> 00:14:53,810 mode, notice that it then does appear, and 378 00:14:53,810 --> 00:14:55,760 when I click on the menu we've only got 379 00:14:55,760 --> 00:14:57,440 just the Settings, which we've set to 380 00:14:57,440 --> 00:14:59,420 never show on the toolbar. So clearly 381 00:14:59,420 --> 00:15:02,240 things are actually working fine. And 382 00:15:02,240 --> 00:15:05,480 notice as well that the Generate option 383 00:15:05,480 --> 00:15:06,680 doesn't appear as well, and that's 384 00:15:06,680 --> 00:15:08,210 correct because we set the visibility 385 00:15:08,210 --> 00:15:10,730 for that to false. So that's good - users 386 00:15:10,730 --> 00:15:12,260 won't be able to use it in the finished 387 00:15:12,260 --> 00:15:13,970 version of the app, which of course is 388 00:15:13,970 --> 00:15:16,040 exactly what we want here. And we'll look at 389 00:15:16,040 --> 00:15:18,080 how to enable that menu, particular menu 390 00:15:18,080 --> 00:15:20,300 item, later in this section. But at this 391 00:15:20,300 --> 00:15:22,490 point I'll stop the video here, and in 392 00:15:22,490 --> 00:15:23,180 the next one we're going to start 393 00:15:23,180 --> 00:15:25,520 creating the layouts that we'll need to 394 00:15:25,520 --> 00:15:28,220 list the tasks and to add new ones. so 395 00:15:28,220 --> 00:15:31,150 I'll see you in the next video.