Join David Gassner for an in-depth discussion in this video Using the exercise files, part of Building Adaptive Android Apps with Fragments.
- View Offline
- This course is accompanied by Exercise Files that you can use to follow along with the demonstrations. I've copied the Exercise Files to my Desktop, but you can place them anywhere on your hard disk. The Exercise Files are organized by chapter. Each chapter contains a folder for each exercise. And each of those folders is an Android Studio project. Each project's core files are under the app subfolder under src, and then under main. There's a java subfolder containing your Java classes, a res subfolder containing resources, and an AndroidManifest XML File.
To use these Exercise Files, you'll need a copy of Android Studio. You can download Android Studio from http://developer.android.com. From the Home Page, go to the Develop link and then to Tools and follow the prompts to download the right version of Android Studio for your operating system. This course was originally recorded with a late beta of Android Studio, version 0.8.2, but the Exercise Files have been rebuilt for the most recent version as of this date.
You should be able to use them in Android Studio 1.1 or later. You'll also need the right API level for the Android SDK. You can check this by going into Android Studio's Welcome screen, clicking on Configure, and then opening the SDK Manager. Check to make sure that you have API 22 or Android 5.1 installed. If there are any minor revisions, just make sure you have the most recent version. You'll also need the correct version of the Android SDK Build-tools.
These versions of the Exercise Files were built with Build-tools 22. You might not see version 22 available, but if you check the option Obsolete at the bottom, it should show up. I recommend installing version 22 of the Build-tools to eliminate any possible errors when you import the projects. To open any of the Exercise Files, go to the Welcome screen and choose Import project. Then, navigate to your Exercise Files folder. You can type Desktop, and you'll jump right to the Desktop folder under your Home folder.
If that's where you placed the Exercise Files, you can get to them fairly easily. Then, go to the chapter you're working on and select the folder for the exercise you're looking at and click OK. That will import the project. You'll be using the original project from the Exercise Files folder. That is, you won't be creating a new copy of it. If you have everything you need, including the right API level, API 22 and the right version of the Build-tools, you should then see this dialogue: Language Level Changed.
And you can click Yes to reload the project. If you're missing anything, you might see an error, but you should see links that let you download the elements of the SDK that you need. Once you've imported the project, you should see a pretty clean layout like this. To find any file, press your Shift Key twice to use Search Everywhere. For example, I'll look for my MainActivity class. I'll type the name of the class, and it shows up. And I'll press Enter or Return to open it.
From there, you can click on this icon named Scroll from Source and that will open up the folder containing the file. And more importantly, it'll open the part of the project that you find yourself working in most of the time. From here, you can get to the res folder and to other essential elements of your project. In addition to the starting Exercise Files, I've also provided a Solutions folder. You'll find the same set of chapter folders there and projects with the same names. These are finished versions of each project.
This will let you look at the finished code and compare it to the starting code.
- Understanding fragments
- Adding fragments to activities
- Creating layouts for multiple screens
- Understanding arguments and callback methods
- Updating apps with support for fragments