Creating Apps with Android Studio

Welcome to Part 5 of this review of the Pluralsight course Exploring Android Studio
by Larry Schiefer


Larry Schiefer

Larry Schiefer is the CTO and co-founder of HiQES, a mobile, embedded, and application development service company. Larry has over 16 years of experience leading teams, and designing and developing high performance and robust software, and is a Google GDE.

Creating Apps With Android Studio


This is a predominantly demo-based module.
Larry explains the core features of the Android Studio development suite including:

  • Creating an activity-based project
  • The basic layout and usage of Android Studio UI
  • Adding and working with Java files
  • Adding and working with XML files
  • Helpful features and built-in

Creating a New Activity Project

In this lesson Larry shows us how to make a simple action bar based activity with fragments.

I am trying out the advice on the very latest (as at 11th June) Android Studio 2.2 preview 3 release so that I can point out any differences to you…

To start, click New Project and fill in these details:

  • Application name: ServiceInfoViewer
  • Module name: app
  • Package name: com.pluralsight.serviceinforviewer
  • Project location: C:\Dev_work\samples\ServiceInfoViewer (or wherever you like)
  • Minimum required SDK: API 15 (IceCreamSandwich)
  • Target SDK: API 19 Android 4.4 (KitKat)
  • Compile with: API 19 Android 4.4 (KitKat)

We see the starter templates. Larry says new templates are being added all the time. He describes and briefly demos these ones:

  • Blank activity
  • Fullscreen activity
  • Master/Detail flow

For more information on Fragments, Larry recommends Jim Wilson’s course Improving UI design with Android Fragments

We choose Blank activity and use these default details on the next screen:

  • Activity name: MainActivity
  • Layout name: activity_main
  • Fragment Layout Name: fragment_main

Larry explains each of the Additional Features options.

We use “Include Blank Fragment”, and Android Studio creates all of our starter files for us in a new project.

Android Studio UI Overview

Larry highlights and explains each of the main UI elements in Android Studio:

  • Project View
  • Package View
  • Collapse Package Tree
  • Flatten Packages
  • Compact Empty Middle Packages
  • Toggle Border controls
  • Structure pane
  • TODO pane
  • Android pane
  • Event log pane
  • Gradle pane
  • Gradle console pane
  • Maven pane
  • Menu bar

Creating UI Layouts

Larry describes fragment_main.xml which is in app/src/res/layout, and the preview pane which shows roughly what the layout will render.

We can select different device definitions, orientations and themes.

Larry points out there are two tabs Text and Design and clicks on Design taking us to a Graphical design for the layouts.

Larry says the LinearLayout performs better at runtime than a RelativeLayout.

We see the error:

Rendering Problems
Except raised during rendering: Binary XML file line #-1: No start tag found!

This means the designer hasn’t found a root layout. Larry says we can ignore this, but we’re about to change it.

We drag the LinerLayout (vertical) onto fragment_main.xml and change the layout:height property to “wrap_content”.

Then we add a ListView. This is found in the Containers directory.
We see a sample view with a list of items with sub-item text.

Next we give it an id of @+id/service_list

We also add a Large Text widget. Because the screen is getting quite busy, drag this over to the Component Tree instead.
When we scroll down to the text property, we see a yellow lightbulb on the left of it.
This gives us the option of creating a string resource.
Another way is to click the button to the right of the edit text field which has an ellipses in it.
Larry also explains how to change the textStyle property to bold.

Next we add a service detail fragment.

File name: frag_srv_detail
Root element: TableLayout

For our details screen, we want to display rows of data for the service, and each row will have two columns: the name of the data, and the data itself.

For the purposes of reuse, we create another layout which has just a table row in it.

File name: item_srv_detail_row
Root element: TableRow

The last part of this lesson covers the XML we need to type in for both of these layouts.

Writing Java Code

In this lesson we add the plumbing for showing the details in, beginning with the PlaceholderFragment method.
We create a RunningServiceWrapper, and add code into onCreateView, onItemClick and onResume.

Next we create a new Fragment called ServiceDetailFragment. We get errors due to the importing an invalid namespace, and change this to
Larry explains all the code we need to add into the onCreateView method for this fragment.

Related Courses

Exploring Android Studio is the 4th course in the Android learning path, which is aimed for .NET developers who are looking to learn how to work with Android and develop apps for the platform.

If you want some additional UI features to go with Cordova, and especially if you already use Angular JS, you should check out Steve Michelotti’s course Building Mobile Apps with the Ionic Framework and Angular JS.

Larry keeps mentioning Gradle throughout the course. If you don’t have any experience with Gradle, you could watch the last two modules of the course before some of the earlier ones.

Alternatively, you can watch Gradle Fundamentals by Kevin Jones

If you are interested in Customizing Gradle, Tim Berglund has produced a Play by Play

Recommended Speed: x1.5

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s