Hire one so that it is literally all you're going to go ahead and we're going to go inside these update
martial our activity class and we're going to actually put some logic's here inside this unclear method.
So first of all in order to identify the martial art object that is actually being updated updated or
being modified We need to have the ID of that specific martial art object.
So let me show you this method here and modify user interface method.
Inside is of the activity of the martial activity class.
Here inside this method you can see that when I created the button for each row actually for each object
in order to mollify or updates that button I said that the ID of that button is the same ID of that
martial art object right here.
So let's scroll down here.
You can see this method here Uncle Meffert right.
Look at this argument here view which is of the view this argument is actually the button that is being
interactive.
Right.
So remember that button is a subclass of view and you can see this argument is the use for user interface
components that is being triggered when the user is actually just interacting with that button.
So this view is the same as that button.
So this means that if I get the idea of this view this means that I am actually getting the ID of that
martial art object.
So let's create a variable of that integer.
And here I can say martial arts martial art object.
The assignment operator view.
I am referring to these arguments right.
That gets I-T semi-colon.
So in this way we can access the ID of the Marshal object that is being actually updated that is being
modified.
Now we need to also have access to the value of the edit texts that we have for each marshal or object
so for each martial art object you're going to have an edit text for the name and edit text for the
price of a martial art and another in it a distaste for the color of that martial art.
So here inside this modify user interface Smurfette you can see that when I created these edit text
here you can see that for the ID of each editor you can see that I actually accessed the ID of the monster
object for example for this one and I and I added about your number 10 to that value or I access them
a marshal ID of the of this object here for this second edit takes which is going to be for the price
of the text right.
And I did a de-value number 22 that ID or for example this one.
So now I can easily access or edit texts inside our row so I can't say for example it edit text I can
create a variable of the text and the name of this editor is EDT.
EDT marshal Anthony EDT.
Martial arts.
N assignment operator and I can say first I need to cestus object to an added text object find view
by id and here in order to access the ID of that martial art.
Actually of that it takes.
That is for the name of that martial art.
We have this idea here right.
So I can say martial art object id plus 10 right.
This ID is exactly the same ID that I specified he had in say this modify use an interface method.
When I wanted to specify an ID for this.
Actually for this ID text for the name the text we can see that here in this number zero.
So in order to access the other additives I can actually do the same here.
So he said his uncle Meffert and below this line of quote I can create another rowdier text.
EDT martial arts.
Price is martial art.
Price assignment operator and I can actually cast this object to it takes the object find view by ID
and an inside Apprentice's just type in here marshal not object id plus 20 right semicolon.
Again create another edit text.
So this time marshal EDT martial arts color so EDT martial arts color assignment operator and let's
cast this object to an editing object.
So here let me put it here.
Let's put up her Apprentice's.
It takes fine view of the martial art object already.
Plus first the semicolon.
So now that we have access to these texts I can access the string value of each edit text so I can create
a variable of type string here and I can say marshal that name string Raddy martial arts name streambed
value assignment operator.
I can access this EDT martial art name that get text get text to string semicolon.
Let's create another variable of types.
So it's three and martial art.
Price string value of martial art
price street value
assignment operator and here I can refer to this EDT Marshall Price that it takes the two strange semicolon.
Again let's create another variable of type screen and its name is martial art color string value martial
arts color screen value streambed value assignment operator anything martial art color that get text
that string semicolon.
Right.
So now that we have access to these city values of this editor access now I can't say so I can't refer
to that database handler reference to this instance that modify I can access this method modify Monstro
not object here.
So here we need to pass the id the martial art name the price and the color.
So we have the ID which is going to be off that interior light and the martial art name is of types
screen.
The martial art prices of type double and the martial art colors of types.
So let's first pass the martial art ID so I can say martial object id come on.
I need to pass the martial art name right.
So I can access.
I can have I have access to that much with that name string value so I can say martial art name street
value karma.
So here we need to pass the martial art price.
It is of type string.
But I'm going to solve it in a moment so for not just pass this value.
Martial art actually priced sitting by the comma.
And finally we need to pass the color so much of that color to city value which is again of types doing
martial art color string value right.
But we have an error.
So let me create a new line here so that you can see these values better.
And let me put it here.
And this one here.
So first we pass them onto the object id which is of that integer and it is a teacher.
And then we passed the marshal named value it is OK.
And here we have a problem Marshall Price string value.
We need to somehow convert this thing about to an integer value.
But in order to do that and use it for example may until later.
Ok for example they use an end to the letter A in the edit text.
So in that case our application is going to crash.
We need to have a tri touch block in order to catch the number format exception so that our application
is not going to crash or we can actually do for example in the catch block we can create a Toastmasters
and we can let the use of know that the value that is going to be entered inside that specific edit
text must be actually a numeric value not a string value.
For example a letter.
So now here let's create a to each block.
Here is Troy.
Open and close the strobe light by using the curly braces after the end in curly brace of the Triple
X just a bit here.
Cheche inside the prentices of this church plug.
Here I can specify the type of the exception which is going to be number format.
Exception.
This is the name of this actually the argument and just open and close this test by using curly braces.
Look at this here.
This method calling here databus handler that modify motional object.
Let's cut the Smurfette here and put it here inside this try block.
But first here before calling this method a modified Marshall object on this database handler reference.
First let's create a variable of type double so double and the name of this variable is going to be
martial art.
Art price double value double value assignment operator.
And here I can refer to this double class that parse double that parse double and I just need to pass
a string value to this method and it's going to convert that value to a double value so that we can
assign it to this variable.
So I can pass this martial art a price string value here.
And finally I just need to put a semicolon at the end of my statement.
So let me create a new line here and here instead of passing marshal price string value to the Smurfette
I just need to pass Marshall Price double value.
So I just need to delete this value and I can say Marshall Price WIOD you that's it.
Now we have no errors here.
Right.
So let's run our application.
But but before that let's make sure that we have actually created an intent inside our main activity
class for this update marshal that activity class so let's go to the main activity class here.
So here is an option item selected Meffert you can see that we have a case for tab at Marshal activity
we have a case for the delit marshal activity.
So we need to create another case here.
Inside is an options item selected inside this main activity class.
So here is just say in case our That ID that update just opened here.
Update marshal.
OK Colin.
So this is this update Monserrat item.
If they use that actually presses this item you are going to create a new intent.
Intent and the name of this intent is going to be actually update martial art the intent assignment
operator new intent and I just need to pass the context.
So I activity that this and for and for the second argument 10:22 activity that we're going to transition
to you're going to move to actually.
So the second activity is going to be update martial art activity that class.
So let me put a semicolon at the end of my statement and then let me create a new line here.
So after this line of code I can actually say start activity and I can't say update marshal activity
intent.
Finally I need to return true for this case or return to suddenly column.
So let's learn our application now.
Let's actually select one of these devices here.
For example this one.
And then click on OK.
So here you can see that our application is running on this emulator here.
So let's actually click on these ellipses a button here this dropdown menu.
So here you can see that we have these items.
So let's click on update the martial arts id..
Now we transitioned to this activity.
So you can see that we have the ID of these martial take is now seven the name.
And you can see it there.
Actually the price this is the color here.
And finally we have this button here modified.
Right.
So.
So you can see that we cannot actually see the entire text of the spot in here.
This button doesn't have enough space to be seen actually on the screen here.
So let's go back to Andrex studio and then let's go to this update.
Martial art activity class here.
So inside this class Let's go to this actually Smurfette modify user interface Smurfette.
And inside this for loop we have a for loop here right inside this wall of where we actually at these
user interface components to the grid play out here.
Let's change the width of these user interface components.
So here I want to tell you that for these I-T takes view here I told you that it is going to actually
take 8 percent of the width of the screen.
So it is incorrect.
Because of the device screen with beat by eight this this means that the screen is going to be actually
divided by eight or in other words it's going to create eight parts for the screen and Vaun part of
that eight parts is going to be actually allocated for this Tayseer for this for the ID text view.
So in order to actually say that all you want.
This idea takes you to take only 8 percent of that screen.
Here we need to say Actually let's put a pair of Prentice's he had integer and actually put another
prophetesses here and here I can see screen with multiplied by zero point zero eight.
Right.
But for this application I want the viewer to take only 5 percent of their screen.
So just multiply these values screen with a by value zero point zero five.
OK five persons.
And then here for this actually for the name it takes here I want this name it takes to take only 20
percent of the screen.
So the value of this screen be multiplied by zero point twenty.
OK.
So in this way it's going to actually take only 20 percent of the screen with this name it it takes.
And this price as it takes I want to actually only take 20 percent of that it takes of the screen.
So it is OK.
And this one color as it takes.
I want to I want this user interface component to this as it takes to take only 20 percent of this cleavage.
And it is also OK.
So now this button here all you want this button to take 55 percent of the screen.
So instead of much vitty change 255 55 screen TVs multiplied by 0.35.
Right.
Let's run an application now.
Let me show you the emulator.
So you have seen our application is running on the simulator.
Let's click on the ellipsis button and then let's see we can update the martial arts item.
So now you can see that this idea is taking only 5 percent of their screen TVs.
You can see that this edit takes here for the name is taking 20 percent of the screen.
This one is a price is actually taking a 20 percent of the screen with it.
So not just that that the keyboard here is actually showing us only the numbers the input type of these
edits is actually the number right input type.
Let me show you this while you type class number here.
And this one the color detail is actually only taking 20 percent of the screen width and the spot in
here is taking 45 percent of the screen.
So here when I actually modify or update one of these marginal objects it doesn't show me a toast message
so that the user know that something is updated.
Let's go to Android studio and let's go inside these update martial art activity class.
Let's scroll down here and it's going into these unclean Metford inside these triple.
After calling the Smurfette modified motional object on this database handle the reference I can create
a toast message so toast that make text first we need to pass the context which is going to be update
marshal activity.
This come on.
And then the message and I can say this that update is updated this martial art object is updated.
Right.
And then I put a comma here.
And finally I need to specify the length of this message which is going to be short.
That should let me create a new line here so that you can see these values better.
And here let's run an application again.
So let's go to the actually it's click on this little button and then click and update the martial arts
item.
So here let's for example change the Spock scene to kickboxing chic boxing.
Right.
Let's get you can modify.
As you can see it's just this martial object is updated.
Right.
So now if I click on actually the back button.
So here you can see the device has a batch button here.
Right.
If I click on it now I am inside this main activity class.
And if you for example go to actually the martial arts item here if I click on it you can see that the
value of the item 7 here is kickboxing.
If I you can go back and if I go again to the update the martial arts activity here you can see that
again the value of the name is kickboxing so you can see that the database is actually updated.
Right.
So that's it.
Let's click on by button again.
So now this is our update Monserrat activity class.
So we actually implemented all these classes where we implemented an at motional activity we implemented
delete much of that activity and we also implemented this update emotional activity.
Now it's time to actually implement the main activity here.
Right.
The main screen that is going to be shown to the user for the first time that for example when the user
runs the application this is the activity that is going to be shown to the user.
This is the luncher activity actually.
So let's go back into the studio and let's see what we are going to do next.