1 00:00:00,470 --> 00:00:05,260 For the rest of these videos, I will be showing how I chose to solve the problem. 2 00:00:05,260 --> 00:00:07,410 There are lots of ways to write an app. 3 00:00:07,410 --> 00:00:10,370 And as long as the app works, you shouldn't be too concerned with how 4 00:00:10,370 --> 00:00:12,920 you got it to work, at least while you're still learning. 5 00:00:14,170 --> 00:00:16,990 That said, I'm going to jump right in and get started. 6 00:00:18,520 --> 00:00:25,860 I am going to call the app Golf Score Card, 7 00:00:25,860 --> 00:00:31,650 and hit next, next, empty activity, next and finish. 8 00:00:31,650 --> 00:00:36,740 Knowing that this activity is mostly just a big list, I am going to start 9 00:00:36,740 --> 00:00:42,130 by extending list activity, remember when 10 00:00:42,130 --> 00:00:46,960 we're extending list activity, our main layout is a list view with a special ID. 11 00:00:48,110 --> 00:00:52,600 Let's go ahead, and make some changes to activity main to make that the case. 12 00:00:55,240 --> 00:00:56,846 I'm going to get rid of the text view. 13 00:01:00,122 --> 00:01:01,404 And drag in a list view. 14 00:01:11,021 --> 00:01:15,262 Then, I'm going to give it the ID of @android. 15 00:01:15,262 --> 00:01:17,820 ID forward slash list. 16 00:01:20,450 --> 00:01:21,670 Looks good. 17 00:01:21,670 --> 00:01:27,065 Now, that I've got my activity main.xml all sorted out, I'm going to create a list 18 00:01:27,065 --> 00:01:33,290 item.xml, which will be the xml file describing each row of the list view. 19 00:01:41,230 --> 00:01:44,648 The first thing I'm gonna do is change the orientation to horizontal. 20 00:01:48,122 --> 00:01:52,932 And let's go ahead, and import the tools name space as well by typing tools, and 21 00:01:52,932 --> 00:01:53,790 hitting tab. 22 00:01:53,790 --> 00:01:56,000 Alright. 23 00:01:58,020 --> 00:02:02,290 From the mock ups, I know that the left most column 24 00:02:02,290 --> 00:02:05,800 is going to be a text view representing the label of the hole. 25 00:02:05,800 --> 00:02:09,310 Which in this case is hole one, hole two, hole three and so on. 26 00:02:10,670 --> 00:02:13,690 Next to that is another text view that represents the score for 27 00:02:13,690 --> 00:02:14,650 that particular hole. 28 00:02:17,060 --> 00:02:22,500 Next to that is a button that will remove a stroke, and 29 00:02:22,500 --> 00:02:24,000 then, another button that will add a stroke. 30 00:02:26,210 --> 00:02:31,200 I'm going to use the lay out width and lay out wait components to make 31 00:02:31,200 --> 00:02:34,990 each of these fit on the screen just a little better. 32 00:02:37,300 --> 00:02:42,384 I am going to set the layout width to zero dp as that 33 00:02:42,384 --> 00:02:47,356 allows us to use the layout_width attribute. 34 00:02:54,501 --> 00:02:55,972 Layout_weight attribute. 35 00:02:57,310 --> 00:03:01,181 And I'm going to set the weight of the first TextView, which is the label, to 3. 36 00:03:06,028 --> 00:03:10,196 The weight of the second TextView, which is the score, or 37 00:03:10,196 --> 00:03:14,460 strokes taken, to 2, and the weight of the buttons to 1. 38 00:03:14,460 --> 00:03:16,504 And then, let's see how that looks. 39 00:03:21,065 --> 00:03:24,518 That looks pretty good, but there's a lot of text on that button, 40 00:03:24,518 --> 00:03:25,760 a lot more than we need. 41 00:03:27,810 --> 00:03:30,785 Probably, pretty safe just using a plus and a minus sign. 42 00:03:36,402 --> 00:03:39,515 And while we're in the text side of things, let's go ahead and 43 00:03:39,515 --> 00:03:41,290 update these IDs. 44 00:03:41,290 --> 00:03:45,430 The first ID should be set to hole label. 45 00:03:45,430 --> 00:03:50,997 And I'm gonna call the second one stroke count. 46 00:03:54,806 --> 00:04:01,080 This first button, I'm going to call remove stroke button. 47 00:04:01,080 --> 00:04:05,225 On the second button, I'm going to call addStrokeButton. 48 00:04:05,225 --> 00:04:06,627 Alright. 49 00:04:08,827 --> 00:04:13,629 Now, the layout dimensions look okay, but the text is a little small, so 50 00:04:13,629 --> 00:04:15,261 I'm gonna change that. 51 00:04:23,692 --> 00:04:27,330 And it's going to recommend that I use SP instead of DP. 52 00:04:27,330 --> 00:04:27,860 So, we'll do that. 53 00:04:30,790 --> 00:04:33,990 And I'm just gonna copy this, and make everything have the same text size. 54 00:04:41,303 --> 00:04:42,670 Alright. 55 00:04:42,670 --> 00:04:47,390 One last step that i'm gonna do is change these text to something more meaningful. 56 00:04:48,930 --> 00:04:51,750 We'll change this one to be whole one. 57 00:04:54,920 --> 00:04:56,150 And this one to be zero. 58 00:04:59,180 --> 00:05:02,210 And then, i'm going to change the name spaces for these two tools. 59 00:05:03,460 --> 00:05:05,970 I don't want these to actually show up in the app. 60 00:05:07,170 --> 00:05:10,110 I'm just setting them to this, so I can look them in the design tab. 61 00:05:10,110 --> 00:05:13,590 And that's what the tools name space is for. 62 00:05:16,330 --> 00:05:19,060 Alright we've created both of our layouts.