Hi everyone.
So now it's time to implement the main activity class.
So first of all just open the app folder and then open the rest folder here inside these terrorist folder
we have this layer folder open it and here you can see the content underlined when that example just
publicly on the spot in order to open this file here.
So this is our content underline minute examen.
And you can see that inside this componentry the constraint lay out a layout is actually the main way
out here.
So at the bottom here you can see this text tap.
Just click on it so you can see that we have actually our concerns they are.
So I don't want a constraint there.
You want a scroll view.
OK.
So let's actually change at this opening tag here you can see the name is Android that supports that
constraint that constraints play out.
So just delete this name here.
I just step in here scroll view.
OK so this is going to be the pattern to play out.
And now let's actually give an ID to this scroll view.
So before the alien tag here of this scroll view let's create a new line.
Just type in here ID and choose and sign Plus Id slash.
And he had to step in here.
The idea is going to be scroll view actually scroll view right.
So this is going to be the ID.
Now let's go to the main activity class here.
So inside these Apfel that open the stub a folder and then open this package.
And here you can see the main activity class doubleclick on this file here in order to make you know
that all of these files.
Now let's double click on this tab here an activity that job in order to make this area right there.
So this is our main activity class.
Let's go to this class let's actually here create some valuables inside this main activity class.
So the first variable is going to be a type database handler right.
So just step here private database handler database handler semicolon create another variable of type
double so private double and the name of this value is going to be total total price total martial arts
price total martial arts price semicolon.
Now let's create actually a valuable or five scroll view so private scroll view scroll view semicolon
and here because I want to actually put the martial art objects as buttons inside our scroll view in
the main activity.
I want to specify that each martial arts button is going to take only a half of the view of the screen.
So just typing here private's it.
Martial art martial art button
semi-hollow.
So here let's go to this uncreate method and let's initialize our valuables that we declared inside
the class.
I mean I think the first value is going to be database handler assignment operator new database handler.
That's it.
And here in say the prentices we just have to pass the context.
The context is main activity that this semicolon.
So now let's initialize this total martial arts prize.
So notice that these variables that we created inside this class are actually instance variables and
instance variables have default values.
OK.
So when I say initialize this means that you want to assign my own value to these variables.
So let's pass the value zero point zero here let's assign this value to these rowdier but total total
Musharraf's price and let's initialises this scroll view.
Assignment operator let's cast this object through to a scroll you object find view by Id find viewpoint
ID or that ID that scurvy.
So notice that we actually created this idea here inside that content and then I mean it is I and if
I go to this fight here you can see that you specified an ID for the scroll view here.
So let's go back to the main activity class.
So here I can say scroll view scroll view sometimes the autocomplete feature of Android studio is nothing
to help you to for example refer to an SMS to a specific ID.
So in that case you just need to manually write that idea here.
Like the style scroll you and then here I need to initialize the mouse in order to actually calculate
the width of the screen.
We need to create a variable of type point so to step in here point and the name of this variable is
going to be screen with screen which is I mean operator new point so at the end of her statement let's
put a semicolon here and let's just type it here get window manager get default display that good size
and let's pass this screen to this valuable here.
So let's change the screen to screen size.
Actually it's more meaningful here.
So the screen size.
Let's change this one to also screen size.
Because here we want to first get the screen size and then we can get the width of the screen.
OK.
So first we have a variable of a point and then we want to get the screen size by just calling to get
window manager to get the part display that gets size so the size is going to be assigned to this screen
size variable here.
Now I can get that screen with.
So now let's refer to our martial art Potten with assignment operator.
So now we have the screen size so the screen size that X semicolon that that's now the width of the
screen is actually assigned to this monitor that button.
But now we want to divide the width of the screen by two.
So this means that the value that is going to be assigned to this variable marshal that button which
is actually half the value of the half of the screen OK half of that half of the width of the screen
actually.
Right.
So this means that I want my button to take half of the width of this screen.
And finally we need to actually call the modify user interface modify user interface and then put a
pair of Prentice's here semi-colon.
So now I told you that root objects are going to be represented as buttons to the user inside the content
and they let me index them and so this means that we need to create a subclass of button called martial
art Potin so that we can actually provide some specific features for that button.
So let's create a new class for that.
Let's open the Android view here.
So you know how to do that you just click on a view at the top to the windows and then project.
And here just open this Joe a folder and then you just select this package directly cut it new and then
just click on jobs class.
OK.
So for the name of the class here.
Just step in here.
Martial arts martial art but in martial arts and so this is the class here don't change anything just
the kind.
OK.
So this is our martial art bottom class right.
Let me just double click on the top here in order to make this area wider.
So here because we want to create a subclass of Potten So we want the same button.
Ok but I want to add some extra features to that button.
So this means that our class marshal of the button must inherit from the app compact button class so
I can say here extends app compact button.
So this means that now our class marshal button is actually a subclass of the bottom class in Android.
So let's go into the curly braces of this class first.
Let's create a variable of type martial arts suggests they can hear Private martial art and the name
of this valuable is martial art object martial art object semi-colon.
Now let's create a constructor for this class.
So just sitting here Puplick martial arts Potten put a pair of Prentice's here.
First we need to specify the context here context comma and then we need to specify actually an argument
or a perimeter in order to initialize or marshal or object body.
But in this value actually so I can't say martial art martial arts.
Right.
So now let's open and close this constructor by using these curly braces inside the constructor.
First need to call the constructor of the superclass which is going to be the app compatibility in class.
Right.
So I can say super And then we need to pass the context.
That's it.
Right now you can see that we have no errors.
And finally we can initialize our instance variables to marshal object.
Assignment operator martial art semi-colons.
I am assigning this argument to this instance variable a martial art object.
Now let's create some Kjetil my fits so I can say public.
And the first method is going to actually turn a string by the way that is going to represent the color
of that martial art.
So I can't say public strange return or get martial art color get that color and then put a pair of
panties here open and close this method by using these curly braces.
And here's just three turn.
Marshall object that color that actually gets rid of color right semi-colon.
Let's create another method so public and here this time I want to return the modular price.
So the return type of this method is going to be double the day of this it is going to be get Marshall
Price get Mosteller price and put a pair of parenthesis here.
Open and close this by using these curly braces return Marshall object that gets Marshall Price semicolon.
So that's it.
Let's go back to our main activity class here.
So this is our master class right.
So let's go back out toward me and I give the class here and let's provide an implementation let's create
a method called modify user interface here inside our class.
So after the in curly brace of these uncreate method I'm going to create that method here so I'm going
to say private's void the name of this if it is modify use interface just with a set of practices you
open and close this method by using these curly braces here.
So now let's pro-white an implementation for this method.