(upbeat music)
Now one thing that can confuse people
new to Android Studio are the templates that
Google include with it.
Especially as they sometimes change them
when they release a new version.
Now I try to keep the course up-to-date,
but with new versions of Android Studio
coming out every few months,
there will be times when it looks that little bit different
to how it appears in these videos.
So I'm going to create a couple of new projects
using some of the templates that are currently
shipping with Android Studio,
and show off some of the ways
that they differ from each other.
Now remember that these are just templates though.
They're provided to save you having to type in
some of the basic code that projects need,
but there's no reason why you can't change
any of the code that the templates create.
If you use a template that includes a menu,
for example, but decide that you don't want to
provide a menu in your project,
then you can just delete the menu code.
And if you've used a word processing programme
such as Libre Office or Microsoft Word,
then you may be familiar with the concept of templates,
and these are really no different.
Alright, so let's have a look at the templates,
and I'm gonna start by creating a new project.
Now if you're watching this video in the Kotlin course
make sure that the include Kotlin support box is ticked.
That's the default, and probably already will be ticked.
So I'm gonna start off anyway, click on
Start a new Android Studio project.
And we can this button that I'm talking about
down here, include Kotlin support.
So again, that's the default, it probably is already clicked
and if you're in the Kotlin course,
make sure that is clicked, but if you're watching
this video in the Java course,
you need to un-tick that box.
Leaving it ticked will cause Android Studio to
generate Kotlin, rather than Java code.
Now I'll mention that each time we create a new project,
at least for the first few projects,
so that you generate the correct code
for the language you're using.
Now I'm going to un-tick the box, that's because Java
programmers don't need to know anything about Kotlin,
but Kotlin programmers will need
basic familiarity with Java.
So whenever our video shows code in both courses,
I'm going to show the Java code.
Don't worry though, if we need to write any code at all,
there'll be separate videos for each course.
So in the Kotlin course, keep that box ticked,
then you can compare the Kotlin code on your screen
with the Java code that's going to appear on mine.
So leave everything else on this screen,
as I said, for this particular application,
I'm doing something a little bit different
and I'm including, and I've unchecked the box
and I'm gonna click on Next.
I'm gonna leave everything else as it is,
and on this next screen we're going to leave
everything else as it is, as well.
Now we're going to be explaining these screens
in the next video, but for now,
I just want to focus on the templates,
so I'm gonna click on Next.
Now at the time I'm recording this,
Android Studio ships with 13 templates,
and the images on this selection screen try to
give an indication of what they contain.
Now, Add No Activity, this one here,
is the most basic, but I generally don't use
that for most apps because we normally need
at least one activity.
Now I'm not gonna go through describing all the templates,
because a lot of the explanation won't make
much sense just yet anyway.
And, in fact, you may be wondering what this activity
that I've just mentioned is.
But don't worry, I'll be explaining all that next.
Now, once you're comfortable, with Android Studio
and you've worked through a few of the apps in this course,
by all means, have a go at creating projects
based on each of these templates
to get a feel for what they provide.
For now the only ones we really need to use
are the Basic Activity and the Empty Activity.
So Basic and Empty.
Now, you can see from these images that Basic Activity
contains a little bit more than the Empty Activity template.
You can see the icon for the drop-down menu at the top right
and it also has a floating action button,
this little yellow button, at the bottom right.
So, if your app will include a menu
or floating action button or both,
then you'd probably be best off starting
with the Basic Activity template.
But if you don't want either of those,
the use the Empty Activity template instead.
But what if you want a menu
but not a floating action button?
Well in that case, you can either start
with an Empty Activity and add the menu code,
or, and this is probably easier, start with a Basic Activity
and delete the code for the floating action button.
So I'm gonna start by choosing this Empty Activity
over here, so we can see what that provides.
Now on the next screen as I click that,
I'm going to leave everything as it is
and accept the default values.
So we'll see this Activity Name and Layout Name
used in a minute, so just remember that they're called
MainActivity and activity_main and click on Finish.
Now Android Studio takes a little while
to create the project, then you should end up with something
that will look a little bit like this,
once this has finished.
So I'll just fast forward this.
Alright so you should end up seeing
something that looks a little bit similar to this.
Now, the version of Android Studio that I'm using
to record this video, starts off in what's called
Android View, after creating a new project.
And you can see this Android tab up here,
in the top left hand corner,
and Android was the default mode that's been selected.
Now some people prefer to work in Project View,
but it really doesn't matter which one you use.
We can switch to Project View, by clicking Project.
And then we can expand this selection of folders
and expand the details out of our application.
Now some of the other views won't show
most of the files we need,
so I won't be using them in this course.
Now, the app that we've created is called MyApplication,
well it's actually called MyApplication2 and that's because
I already created one previously called MyApplication,
and I expanded that view and you saw that we saw
there was this app folder, expand that, click that open.
And this is where most of the files
we're interested in are located.
Now in Android View, if we switch back to that,
the app folder is at the top level,
this one here, and I can expand that out.
And this is why many people prefer to work in that view.
More files are visible in Project View, but most of them
are the ones that you don't generally need to worry about.
The main files we have to change or create,
are in this java, or res folders,
or if we switch back to Project View,
we can expand that out and we've still got the src,
main, and we've got the java and res folders here,
they're just a little bit,
in a slightly different location when in Project View
compared to Android View.
So it's the same set of files essentially,
just presented in a different way.
So choose whichever view you're most comfortable with,
I'll be mainly using the Android View in this course.
Now, over on the right hand pane, up here,
there's two files open,
activity_main.xml and MainActivity.java.
Now these are the names of the Activity and the Layout
from the earlier screen.
Now, if we close these, we can open them up
by just opening the particular folder,
in the case of the java folder, we can double click
MainActivity to open them up, and the activity_main
we can look in the layout folder, and double click that
and open it up like that.
And again, going back to Android View,
we can see essentially the same thing.
Opening up we can see that our MainActivity file is there,
then in the res folder, in the layout folder,
there's our activity_main.xml.
Now the activity_main.xml, defines what
the screen for the activity will look like,
and if I go into this Design tab,
which is selected currently anyway,
you can see that it looks very similar
to the template image.
There's no menu icon showing and no floating action button,
just the text Hello World, as you can see there.
Now MainActivity also doesn't contain very much,
if we have a look at that.
Don't worry about what any of this code means at the moment,
I'm just showing you what the templates look like
so you don't get stuck when Google changes them again
in the future.
And also, don't worry that this is Java code,
if you're watching this in the Kotlin version of the course,
anything we do with the screen layouts is the same,
regardless of the language used, so some of the videos
are the same for both courses.
Now we can see that we've got a class here called
MainActivity and that's got a single method called OnCreate.
So class name, method name.
Make a mental note of that, and then we'll see
how the next template differs.
So what I'm gonna do now though,
is end the video and in the next video
we'll go ahead and we'll create a second project,
this time based on the Basic Activity template.
So I'll see you in the next video.