High students.
So now it is teetotally I want to talk about pop up window in Android.
So let's create an android city or project the application is going to be pop up window and you can
specify the company domain package name and the project location here which is the next.
So here for the minimum STK choose API 16 Android 4.1 Philipine and then click next and he has to choose
interactivity next.
And then he can specify the activity name here and then click and finish.
So now as you can see here our project is actually created so it's actually with a little bit now.
OK.
The project is ready so let's go to this activity under last minute exam and in order to design the
user interface our application.
So let's select this hello world text and then delete it.
And now let's actually just track a pothead into this play out here.
So inside these widgets folder just select a spot and just strike it here at the center of this layout
and select the spot.
So for the idea to step in here Pythian show pop up window between show of a window and that person
into your keyboard and then for the text that's attribute here to stay in here show pop up window
and then person until the key on your keyboard.
So now let's create another XML file in here.
Inside this layout folders are just open displays folder here and then open this layout folder and at
the top just get you can find new and then click on layout resource void.
So for the file name here I can say pop up the filename is going to be pop up on the line window.
So make sure that your file name starts with a lower case letter.
As you can see here pop up on the line window the root element is going to be linear lay out the source
said is main and the directory name is a lay out and then click on OK.
So now we have this pop up on the line.
We know that XML file inside this ex-directory.
So now with this pop up window selected here at the border and just click on a text tab here.
So now you can see that we have this linearly out here.
So the orientation is where it's called out which is mass panic and the lever height is much parent.
Right.
So because this is going to be the pop up even though Let's change the linear length to a relatively
out and because this is actually relatively out we don't need this orientation attribute.
As you can see here this orientation attribute is only used for linear layouts.
So let's delete it here.
So we have only the lay out and the height attribute.
And now let's go to the Design tab here at the bottom.
And now I can actually track a text view here.
So let's say like takes you inside these widgets folder and just throw it here at the center of this
pop up view here inside is relatively out.
As you can see so look at these guidelines.
These dotted lines that is actually specifying that I am actually putting the space in at the center
of this relative out.
So this is my take.
Let's try an image button here or we can actually see it right an image view here an image.
So let's actually just find these images and media there.
And just like this image for you here just select this image and just like it here at the right hand
side of this relatively out.
And look at these guidelines here.
Look at this out all that is especially specifically that I am actually putting this image for you.
According to the right hand side of the relatively out and just really sit here and now are actually
specify an image.
I don't want to specify any image here.
So let's click on cancel here as you can see if you click on cancel.
You cannot actually just put this image through here.
So we must actually select an image here.
So let's take it just like it here and put it here and now as you can see we must select an image.
So just select is Eisley luncher and then click on OK.
Just this is just a placeholder.
So and now we have this text view we have this image.
So let's just drag a button or we can actually track Yes.
Let's try a bottom here.
I think at the right hand at the left hand side of this relatively out as you can see.
So just really sit here.
So I notice that I am positioning these components in one light.
Right.
So this is really important to just really sit here.
So now I have a button takes you and an image view.
So now let's pro-white an image for this image view here.
So let me actually show you the photos so you can actually download this image from the resources section
of this lecture.
So let's just copy this image and then here I can just go here inside the structure and the structure.
And I can select this triable folder inside the Swiss folder and then just right click on it and then
click on paste.
So now just click on OK.
And now we have this image flubber that PAGG here and now I can just open the view all properties here
and I just need to search for S R C attributes.
So in order to search for a specific property you just need to select one of these properties here and
then just type in your specific property that you are looking for.
So I am looking for this attribute.
So this is this is that's the attribute and here I can just click on this ellipsis button this button
here.
Dot dot dot.
And now here as you can see the joy is selected.
And now I can actually search for the name of the emet flavor.
So here is that flavor image.
And then we can.
OK.
And here are actually I actually specify the image of this image view to be Flubber.
But as you can see the image is not changed.
Let's actually search for it as compact as soci compact So as you can see the RC compact is says that
the image of this image is going to be ice icy luncher.
So let's actually swell you here and then present it on your keyboard.
So now you can see this image here.
And now as you can see the height and width of this image is too large.
So let's actually decrease the beach and the height of this image.
So at the top for the layout which is about 100 or even 50 percent the value of 50 for the beach and
for their height for the length height assigned the value 50.
So now we have these image lay out piece under the height is 50.
So now if you have this takes view so this selectees takes view and let's actually search for the text
attribute.
So again select one of these properties and search for text attributes.
So as you can see at the bottom here we have some of these attributes but we do not have the specific
text attributes.
So this is the text attribute here.
And I can't just type indices pop up view pop up if we do actually.
So here it is the text and I can actually select the spot.
And for the patent for the ID just type in here between close and in person into the general keyboard.
So we put the spots in here in order to allow the user to close the pop up window and search for the
text attribute of this button switch or step into your text.
Here it is the text attribute.
And for the text that appears just step in here close and then present it to you on your keyboard.
So now we designed the user interface here and now it's better to actually go to this activity underlaid
minute segment here and let's actually change the background color here of this relatively or so just
select it's relatively old and that you can actually go to this view all properties and search for background
by going.
And here it is back in the attributes.
And here I can say for example hashtag of 5 5 5 5 and then person enter here on your keyboard.
So I changed the background color of my left relatively out here and now let's go to main activity.
Java here.
And now let's just actually create some properties here let's create some variables.
So the first variable that you want to create is for the Spartan.
So now I like you to go to the main activity that a file on inside this class.
I can just say a private Botta PTEN and the name of my variable is going to be between show and she'll
pop up window
and then just put a semicolon at the end of your statement.
And now let's go into this.
Insight is on create Mefford analogy instead between a show a pop up window assignment operator and
just put a pair of pants.
And so the instead Apprentice's just cast this object to a button object and just type it here find
view ID are that ID that and show up of a window semicolon.
And here I can say a bit here and show up in that set and click listener new view.
So just put the new keyboard and the capital V.
And now the autocomplete feature of anthrax that you is going to help you to choose this option.
Uncle listener.
So look at this syntax.
We have these curly braces and inside these curly braces we have dot dot dot.
So choose this one and that person have on your keyboard.
So now the autocomplete feature of Android suit you put these codes here for me automatically.
So now let's go inside is unclear each method here.
So here in order to create a pop up window we need to create a valuable of type layout inflator.
So here I can just type in LeAnn's inflator and the name is going to be laid out inflator assignment
operator.
So notice that this is just the variable.
This is the name of my body.
And we are going to actually create the actual object here at the right hand side of the assignment
operator and we're going to assign that object to this value which is of inflator.
And this is the same actually the case for this but in here we created this variable which is of the.
And in line number 20.
And inside this uncreate method we actually referred to the actual button object.
We just it means that we created about an object actually and the assigned that reference to this between
and she'll pop up the window Vaadia which is of the bottom.
And now here after this assignment operator here I can actually say first we need to actually put a
pair of pants here in order to test this object that we're going to create two and two are layette inflated
object.
So inside Apprentice's just the left inflator and then just type in here get base context.
So as you can see the skit based context is going to return a value of type context.
So in this way we actually have access to the context and by having access to the context we can have
access to all the services outside of Android outside of the current context which is the actually the
main activity.
So I can say database context that gets system service and insight Apprentice's just a bit here to lay
out inflator service semi-colon.
So let me create a new line here so that you can see these values here better.
So I created a variable of the play at inflator and then I cast that object to our last inflator object.
And then just typing here a guess based context to get system service lay out inflator service.
And here I can I can actually say view.
So I'm going to create a valuable type view.
Right.
And the name of my variable is going to be Pop-Pop you.
Assignment operator and now I'm going to refer to this layout inflator.
So layout inflator does inflate.
So as you can see here we have different versions of the Smurfit here.
So let's actually just type in here.
Inflator that inflate.
Let's use this one and you can see this version here.
For example this version for the first argument accepts a value of the integer and the name is a resource.
Right.
So now we need to specify the resource.
What is the resource that resources that actually pop up into that exemplified.
Right.
So here I can see our data lay out that pop up window come up.
And for the second argument we don't want to actually pass any arguments here.
So we just about the value null here.
So this is going to be the root of we don't want to pass the root here because we are actually putting
the pop up view on them actually with the other limited access.
And so we don't need to specify that value here.
Now we need to create and of a variable of type pop up window.
So let's scroll to the top and inside this class main activity class let's actually create another value
but so private and the name of my variable is going to be pop up window and the name of this variable
is going to be pop up into a semicolon.
So we just declared this variable here right.
Let's scroll down here.
And now inside is Uncle Camelford.
And when I say a pop up window pop up window.
Assignment operator so now I'm going to I'm going to initialize these variables here.
So now I'm going to create an actual object of type pop up window.
So just type in here new and just type in here pop up with capital a pop up window.
And now we need to pass some arguments.
So the first argument that I'm going to pass is going to be the context or the view.
Right.
So we already created this view here.
This view about evil.
This pop up view that actually uses the and inflator in order to inflate the view.
So for the first argument we passed the pop up view here come up for the second argument if you need
to specify the Viets of a pop up window.
So we want to actually put the pop up window inside a pop up view.
And now we need to specify the width of our pop up window.
So this is going to be so just typing here relatively out.
So we are used to relatively out because let me actually show you the pop up window that is him and
and at the bottom.
If I actually click on this takes step here as you can see we have actually relatively out here right.
So that's why here inside this main activity that of a file for initialising does pop up into our used
relatively out so relatively that lay out Putnam's with a capital M L actually lay out perhaps that
rap content comma.
So this is my actually which of the pop up window.
And then again just type in here relatively out.
Now I'm going to specify the height that lay out perhaps that's the rap content semi-colon.
So let me create a new line here so that you can see these values better.
So I specified the beach and the height both of them got content and now I can't say.
So now we need to specify the location of our pop up window inside our activity and the like minute
exempt.
So when I when I actually actually condescend to use that actually touches this BT and Sharpeville window.
It can actually show a pop up window to the user.
But now it wants to actually it wants us the Android wants us to actually specify the location of the
pop of being inside that a view inside that activity Underland minute example.
So how we can specify that.
Let's go through this activity underly minute exam examined here and now let's select this activity
on the line.
This is actually a relatively short flight and for the idea is actually give an A meaningful ID to this
relatively well.
So let's actually just name it relative lay out as the id and then press an entry on your keyboard.
So I assigned the value relative ID relatively and actually to the ID attribute of this relatively out
inside this activity underlayment and examine.
Let's go to the main activity that Java file and at the top let's create another variable so private
and Riehle type is going to be relatively out and the name is going to be relatively semi-colon.
Let's go to this uncreate Smurfette.
Now after this line of code that actually initializes disputant Pythian pop up window.
Let's initialize around the table which is of type relatively out so I can say relatively else.
Assignment operator and inside Apprentice's I can just specify that this object that are going to create
is going to be of table relatively.
So I think this object to a relatively old find view by id art does lay out order are actually are Id
thought a relative lay out semi-colon because of the fact that they left relatively out of value as
the id of these relatively insight or activity underline minute segment and now we have this relatively
out.
So here I can actually say it is unclear that after this line of code that actually initializers this
pop up window I can actually say pop up window that location show as location.
And now we need to pass some arguments to this Smurfit.
The first one is going to be the parent.
So what is the parent the parent is going to be.
They are relatively out right.
So we want to put this pop up window incited activity and eliminate examen So we have to relatively
have as the parent of the pop up window that you want to show to the user.
So lets go back to this minute activity that job offer here inside this ugly.
And as the argument as the first element I'm going to pass the value relative lay out OK.
Come on now we need to specify other arguments here.
So the are the other arguments is going to be the location of these parents so the location is going
to be gravity.
So after this come I just step in here.
Gravity that center with capital C gravity the center comma and then we need to specify the X.
So for the expertly press the values 0 we always pass the value 0 for the x and y.
I actually passed the value 0 again because I actually said OK the parent is relatively out and I want
to put this up pop up into the center of our relatively and so forth.
And the way we passed the values zero are because we dont need to actually pass any other values and
they are 0 for the X and 0 for the Y means.
And actually at the top left corner of the actually a pop up window.
So we pass zero and zero and then we show that value is a pop up window on this relatively out.
So now let's do another application and let's see what happens here.
I just need to specify our device and then we can OK.
So as you can see here our application is running on the simulator.
So now let's actually click on the spot in.
And now we can see this pop up window here.
Right.
So we have this close button we have this text which is not shown here actually perfectly and we have
this image here.
So Vinita actually just specify that.
OK.
I cannot close this part of it.
Now I need to actually just create a new listener for the spot for this close at hand.
So that when they use that actually touches the spot in the pop up window is going to be closed and
you're going to be guided to there are mainly out.
So let's go back to android studio here.
So now after this line of code here that actually specifies the location of the pop up window here I
can actually say so here I can create a value of type buttons so button PTEN close assignment operator.
So a way to pay attention here.
I'm going to actually cast this object to a button object here and now I am going to refer to this pop
up view.
Why.
Because the actually the button the close button is actually inside the pop up window and the pop of
window is actually inside a pop up view.
So in order to refer to that button all you need to actually refer to the pop up view.
So here I'm going to say pop up you got and now I can actually search for that specific button for that
close button pop up you that find the ID or that ID that PTEN close semicolon that deputy and close
is inside a pop up view.
This is really important if you don't put this pop up view here your application is going to crash.
So I went to create a listener for the city and close so between close setup click listener new view
that Uncle listener and insight is un-Christian if it were to say just pop up even though that the Smiths.
So now let's try another application and let's see what happens.
Let me show you the emulator and now I'm going to click on the shop window.
So this is a pop in the here and now I am going to click on the close button.
So another pop up in do is actually close.
Let's click on this one again close again.
So now let's actually solve the problem with these components here.
So I don't want this close button to be here.
I want this coolest button here to be according to the left hand side of the device of the screen actually.
And I want to see the whole value of this text here.
So let's go back to android studio and let's go to this pop up on the line of Windows that exemplify.
Let's go to the design tab.
And now let's actually just select this text here.
This text view.
And let's actually put it here.
And let's select the spot.
Just like it here to the left and let's select this takes you and just like it here a little bit to
the left here.
And now I think it's fine.
So let's actually run an application again.
Let me show you the emulator
let me click on this show off a window and now I can see this button here close and I can see this it
takes you and I can see this of you but you can see that at the below Actually it'd be really out there
relatively old blue below this pop up window.
It's actually not.
It's not allowing us to see these values these components clearly.
So let's go back to android studio.
So there are two ways to solve this problem.
Let's go to a main activity that you have a file.
And after this line of code that actually sets the location of the pop up window that is it can actually
set the location of the pop up into and it's going to show that pop up window on that location after
this line of code here.
You can say PTEN sure of a window that said visibility view that invisible right.
And after we actually did it click on this pop up view pop up window that dismiss here.
I can actually say a bit here and show pop up window that said visibility view that visible.
So let's run our application now.
Now let's click on this.
Sure pop up window and here you can see that the button that between show up a window is now invisible.
Right.
And if you actually click on this close button again.
Now this button is visible.
If I click on it again.
Now we have this pop up window and the BT and sure pop up window here below is a pop up into it is now
visible invisible.
And if I actually click on this close with and again it is now visible.
So this is one way to solve this problem.
Another way is to actually go to these pop up window that exemplified here and I can just select this
relatively out and now I can get you to specify a value for the background color.
Right.
So here just select is relatively out and inside this property section I can select one of these properties
and search for background attribute or I can actually go to these text type here at the bottom and here
at the top as you can see we have this relatively off right.
So below this ending type I can actually just type in here background and I can actually paste this
value here hash tag 41 69 eeven.
So this is actually a color you can see this color here.
And now let's go to our design Tatman and now you can see that the back in of the relatively is now
changed.
Let's run an application here.
Let me show you the emulator.
So now our application is running.
Let's click on the shop window.
Now you can see that the background color of this actually of this pop up window is now this color is
now changed.
Let's go to this activity.
Let's go to the main activity that of a fine.
And here let's comment out these codes that actually sets the visibility of the BT and sure pop up window.
Let's run the application again.
Let me show you the emulator.
Now let's click on this.
Sure pop up window and here you can see that I'll do that but it is below these pop up window.
You can actually see these pop up into here we can see all these components.
The button the text and the imagery you click on this close here.
So now it is gone.
So I think that's enough for this application.
And if you have any questions about pop up into Android please post the discussion in the course and
then I'll do my best to answer all of your questions.
Thank you very much for watching and seeing the next 30 odd.