1
00:00:00,210 --> 00:00:02,500
Hello this is Martez or karate.

2
00:00:02,610 --> 00:00:09,450
And in this material we are going to completely implement our constructor here inside is my custom view

3
00:00:09,450 --> 00:00:10,330
class.

4
00:00:10,410 --> 00:00:16,220
First of all we need to create some instance valuables inside our class so let's do that now.

5
00:00:16,230 --> 00:00:23,560
So remember what I told you about instance variables always declare your instance variables as private.

6
00:00:23,730 --> 00:00:25,520
So let's do that private.

7
00:00:25,800 --> 00:00:32,400
And now we need to specify the type the type is going to be of the integer The name is going to be View

8
00:00:32,580 --> 00:00:38,300
color semicolon private in teacher.

9
00:00:38,380 --> 00:00:43,050
And here we need to specify the text color which is a can of type Integer.

10
00:00:43,210 --> 00:00:50,180
And finally private's 3 and it is green and its name is going to be view text semicolon.

11
00:00:50,530 --> 00:00:55,360
So you can see that I declared this instance variables here right but let's switch to the my custom

12
00:00:55,360 --> 00:00:57,430
view attributes that XML file here.

13
00:00:57,460 --> 00:01:05,470
We created these attributes and according to these attributes I created instance variables inside my

14
00:01:05,470 --> 00:01:07,090
custom view that Lafite.

15
00:01:07,120 --> 00:01:15,130
So remember that whenever you create an attribute inside your XML file for your custom view make sure

16
00:01:15,130 --> 00:01:20,500
to create an instance variable that is related to that attribute inside your class.

17
00:01:20,500 --> 00:01:22,780
So here we created this instance variables.

18
00:01:22,780 --> 00:01:25,030
Now we need to go inside our constructor.

19
00:01:25,030 --> 00:01:30,670
So after calling the super constructor we are going to initialize this instance variables.

20
00:01:30,670 --> 00:01:37,570
So how we are going to initialize these instance variables by accessing the attributes that we put inside

21
00:01:37,590 --> 00:01:42,890
are my custom view attributes that identify by accessing these values.

22
00:01:42,950 --> 00:01:45,930
We are going to initialize our instance variables.

23
00:01:45,970 --> 00:01:52,900
So that's why I told you whenever you put an attribute inside your custom view that exemplified make

24
00:01:52,900 --> 00:01:59,530
sure to create an instance variable inside your giallo fine for that specific attribute.

25
00:01:59,530 --> 00:02:03,370
So we need to get inside my custom view that have a file inside the constructor.

26
00:02:03,370 --> 00:02:12,070
After calling this Super constructor we're going to create something called typed Aure typed at 8 so

27
00:02:12,070 --> 00:02:13,820
the name is going to be typed at 8.

28
00:02:13,840 --> 00:02:14,820
Assignment operator.

29
00:02:14,830 --> 00:02:24,390
Now we're going to say context that gets Feme that pain styled attributes.

30
00:02:24,410 --> 00:02:29,870
So now first as you can see if you need to pass the attribute said call this function again you know

31
00:02:29,870 --> 00:02:35,830
that just to show you these attributes these arguments that going to pass to this function.

32
00:02:35,960 --> 00:02:39,320
First if you are going to pass the attributes set and then.

33
00:02:39,360 --> 00:02:43,210
So let's actually pass the attributes here attribute set comma.

34
00:02:43,250 --> 00:02:50,180
Now we need to pass the resource phi or the exemplify that we created for a custom view in order to

35
00:02:50,180 --> 00:02:52,340
specify the attributes.

36
00:02:52,340 --> 00:02:57,170
So we are going to say our DOT style of Eldard.

37
00:02:57,260 --> 00:02:58,940
So here it is really important.

38
00:02:58,940 --> 00:03:05,540
Let's go inside are my custom attributes that is in a file here as you can see we created attach called

39
00:03:05,840 --> 00:03:07,260
declare style.

40
00:03:07,310 --> 00:03:10,030
Its name is my custom view.

41
00:03:10,130 --> 00:03:10,800
Right.

42
00:03:10,940 --> 00:03:13,230
So now we're going to refer to this name.

43
00:03:13,340 --> 00:03:15,800
Let's go inside are my custom be that have a file.

44
00:03:15,800 --> 00:03:25,140
So it is our database that my custom view karma to specify a default value for this type attributes

45
00:03:25,140 --> 00:03:30,220
the let's pass zero comma and again zero as the final argument.

46
00:03:30,260 --> 00:03:31,620
So let me show you these arguments.

47
00:03:31,620 --> 00:03:37,000
Here we have this default style attribute zero undefined style resource.

48
00:03:37,190 --> 00:03:39,870
So let's put a semicolon at the end of our statement.

49
00:03:39,950 --> 00:03:43,440
Let me create a new line so that you can see what's going on here.

50
00:03:44,320 --> 00:03:51,310
So first we passed the attributes set that we get from this a constructor and then we are passing this.

51
00:03:51,310 --> 00:04:00,760
Name the name of our custom view our style that my custom view and the value zero as the default style

52
00:04:00,790 --> 00:04:01,470
attribute.

53
00:04:01,480 --> 00:04:04,990
And about you again 0 4 the default style resource.

54
00:04:05,170 --> 00:04:13,540
Now here after that you actually created this typed Arri we are going to create a try catch statement

55
00:04:13,540 --> 00:04:18,070
here try and catch some exception.

56
00:04:18,460 --> 00:04:21,130
So let's open and close this block by using these collaborations.

57
00:04:21,130 --> 00:04:22,240
Let's go into these tribal.

58
00:04:22,240 --> 00:04:25,860
So you are actually putting all coats here inside this right block.

59
00:04:25,870 --> 00:04:31,340
Maybe actually something goes wrong so that we can actually catch the exception here because you're

60
00:04:31,360 --> 00:04:33,540
dealing with a typed error.

61
00:04:33,550 --> 00:04:36,390
Now we can initialize our instance variables.

62
00:04:36,430 --> 00:04:39,050
So the first instance variable is view color.

63
00:04:39,070 --> 00:04:42,390
So now we can say View color assignment operator.

64
00:04:42,400 --> 00:04:44,740
Now we have this tied at a right.

65
00:04:44,800 --> 00:04:48,550
So let's say types are a data type of our view color is integer.

66
00:04:48,670 --> 00:04:52,160
So now we can see that gets in teacher.

67
00:04:52,210 --> 00:04:57,300
Our dot Styler bill that.

68
00:04:57,530 --> 00:05:04,550
So now we can access the color attributes the view color attributes that we created inside our my custom

69
00:05:04,550 --> 00:05:05,970
view attributes that exemplify.

70
00:05:05,990 --> 00:05:15,500
So we can say my custom view because the name of that style label attribute is my custom view and then

71
00:05:15,560 --> 00:05:17,460
we have this text color.

72
00:05:17,570 --> 00:05:20,600
We have this view color and this we have viewed text.

73
00:05:20,600 --> 00:05:21,810
So we have this view color.

74
00:05:21,860 --> 00:05:23,100
Let's use this one.

75
00:05:23,450 --> 00:05:30,020
And we need to put a comma here and provide a default value for our attribute here semicolon.

76
00:05:30,620 --> 00:05:32,170
Let me create a new line here.

77
00:05:32,180 --> 00:05:36,060
Now the second instance variable that you want to initialize.

78
00:05:36,200 --> 00:05:38,210
Is this a text color.

79
00:05:38,210 --> 00:05:45,770
So let's say text color assignment operator again typed every that gets in teacher.

80
00:05:45,810 --> 00:05:54,660
And here are dot style level dot my custom view and lets access this one text color comma and then this

81
00:05:54,800 --> 00:05:57,470
has the value 0 as the default value semicolon.

82
00:05:57,500 --> 00:06:03,330
Now let's initialize the view actually not the text.

83
00:06:03,500 --> 00:06:10,050
So we have this mutex assignment operator times Ari that jet stream.

84
00:06:10,060 --> 00:06:11,390
This time it is of type string.

85
00:06:11,390 --> 00:06:13,170
So we get this strange.

86
00:06:13,640 --> 00:06:21,540
And we see our That style liberal that my custom view view text semicolon.

87
00:06:21,590 --> 00:06:29,950
Now inside this catch block we can say pipes aere that recycle.

88
00:06:30,010 --> 00:06:33,310
So let me hold a comment on my keyboard.

89
00:06:33,390 --> 00:06:36,910
You can actually do that and then click on is recycle here.

90
00:06:37,860 --> 00:06:42,840
In order to see the documentation of this method if you are using a Windows machine you can hold down

91
00:06:42,840 --> 00:06:46,920
the control key on your keyboard and then click on that second method.

92
00:06:46,940 --> 00:06:48,810
Here take a look at this documentation.

93
00:06:48,810 --> 00:06:56,010
Here take a look at this comment it says a recycles the typed Aure to be reused by a ladle color.

94
00:06:56,010 --> 00:07:03,520
So if anything goes wrong in initialising odd instance variable this recycle is going to actually the

95
00:07:03,550 --> 00:07:06,690
pipes are ready to be reused by a later color.

96
00:07:06,690 --> 00:07:08,510
Let me close this file here.

97
00:07:08,550 --> 00:07:11,660
Now that the initial eyes are instance variables.

98
00:07:11,660 --> 00:07:15,300
Again I think that's enough for this tutorial in the next tutorial.

99
00:07:15,570 --> 00:07:18,520
We're going to implement the underarm effect.

100
00:07:18,570 --> 00:07:20,910
Inside are my custom view class.

101
00:07:20,910 --> 00:07:22,500
Thank you very much for watching.

102
00:07:22,830 --> 00:07:24,590
I'll see you in the next tutorial.

