Exploring a Basic Activity project
Let's look at the Java code first in the MainActivity.java
tab in the code editor. As already stated, a Basic Activity project has more to it than an Empty Activity project.
Note
You can open as many instances of Android Studio as you like. If you want to compare projects side by side, select File | Open then choose the project, and when prompted select New Window to open the project, without closing any projects that are already open.
The first thing to note is that there is some extra code in the onCreate
method.
The MainActivity.java file
I mentioned very briefly back in Chapter 2, First Contact: Java, XML, and the UI Designer, these interconnections in the Java code and the XML code. Let's look through the resource files and point out the XML files that this Java code points to.
Here is the Java code shown next. I have slightly reformatted it to make it more readable in a book:
Toolbar toolbar = (Toolbar) findViewById...