Welcome back and this video, we are going to implement a little feature which will allow us to use
something on the map.
For now, it will just be the map.
So we will see a map activity.
But later on, we will add the feature, which allows us to view the actual location of this happy place
on the map.
All right.
So that's what we're going to build for now and therefore we need to create a new activity.
So let's go ahead and do that.
I'm going to create an empty activity, which I'm going to call map activity.
And then in the manifest, or first of all, here, you can see are has to be imported, so it doesn't
know our.
Direction for our the directory, and then the next thing is that we go to our manifest and here I'm
just going to set up the same settings as for the other activities.
So custom, no bar theme or no action bar theme, it will be portrayed and here, happy place.
OK, so then the next thing is going to be is to design the activity map.
So this activity map XML because in here I want to use a map fragment.
So here, first of all, we should have a toolbar.
So let's just add a toolbar as we've done in other cases.
So it's pretty much the same thing.
The only difference to other toolbars that we've created so far is the ID here will be toolbar on the
score map.
And now in here I would like to create a map fragment and in order to do so, you can just use the fragment
keyword and then you have to assign a width.
So I'm going to say it should match its parent in both directions.
I'm going to give it an ID, which I'm going to call map.
And then on top of that, I want to assign the constraints.
It's going to be the following ones.
So bottom to bottom of parent, end to end of parent, start to start of parent and top to bottom of
toolbar.
So it should be underneath the toolbar there.
There's one more setting that we need to add here, and that is we can assign a class here, which I'm
going to assign to conduct Google Dot Android to GM's maps that support map fragment.
Because we want this fragment to eventually be our map, our Google map.
All right.
OK, so then in our activity, happy place detail, so in the resources, I would like to add a button.
So let's go to this layout.
And add a button to the very bottom.
OK, so here it should be inside of the scroll view and inside of the constraint layout, but it should
be underneath the lowest tax to you or dipsticks to you, which is our TV location.
So in here, I would like to have this button and it's going to be a generic button so you can see.
Much parent, and it's with so it's going to be pretty wide.
It's just going to be as high as it requires.
It's going to be centered.
It's going to have margins.
And the background should be a shape button around it, which we have used before.
And so we created this back in the day and another lecture.
And as you can see, there are a bunch of new dimensions and also new strings.
So the textured button takes view on map.
So let's add all of those dimensions and also those strings to our project.
So here in dimension's, as you can see, we have already and many different dimensions, and here this
one will be putting you on margin stardate density pixels, margin top 16, putting top to bottom eight
density pixels and textiles will be 18 Hespe.
And then we had one string, so let's go to strings and add that one string, which was just a button
text.
So button text view on map.
View on map.
And now we just need to give this button your map, which we just created, which is in our activity,
happy place here.
This one, we need to give it an unclick listener.
So on which page is it?
Well, it's on the happy place detail activity.
So let's just go there.
Happy place, detail activity.
And here we will add another listener to it.
So as we've done with the other ones, we're just going to keep it simple here.
So.
Just going to say putten view on a map set on Click Listener.
And then we use the curly brackets here.
I just want to have an intent here.
Which will open up the map activity.
So here we need to import intent.
And then we need to put this into context, so I'm going to pass on this and also the activity that
we want to go to, which is our activity, right.
So map activity class that Jabhat.
All right, and then the next thing is, of course, to start this intent.
But I also want to pass something, so when I click on this, I want to give this intern some extra
information, which will be our main activity, that extra place details.
So let's get them here.
Extra place details.
And the detail itself will be our happy place detailed model.
So this object that we created earlier on, which is this one here.
All right, so we passed that as well into intent and then we start the activity, start activity with
this intent.
We prepared.
All right, at this point, we should be able to get this running and test the functionality.
All right, there we had our test one, and you can see the view on my is there.
Let's click on it.
And let's see if the map opens and there you are.
So the Google Maps activity opened up and now we can see the map.
Of course, we don't have any controls.
We don't have any additional detail.
And as you can see, there is no action bar here.
And that is because I didn't assign the right height here for this button and this activity map.
So here I used my parents, but we could, of course, also use zero density pixel so that our toolbar
still has some space.
So testing that once again and going to our map.
We can see now the toolbar is still there.
All right, so now that we have the map here, it's time to display the right location on the map,
so let's add a little marker to it and the next video.
See you there.