The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Tutorial #7 - Setting Up the Action Bar

Next up is to configure the action bar to our EmPubLite application.

This is a continuation of the work we did in the previous tutorial.

You can find the results of the previous tutorial and the results of this tutorial in the book’s GitHub repository.

Starting in this tutorial, we will now begin editing Java source files. Some useful Android Studio shortcut key combinations are:

Step #1: Adding Some Icons

We are going to need a couple of icons for our action bar items. Nowadays, the preferred approach for doing this is to start with vector drawables.

Right-click over the res/ directory and choose New > “Vector Asset” from the context menu. This brings up the first page of the vector asset wizard:

Android Studio Vector Asset Wizard, As Initially Launched
Figure 221: Android Studio Vector Asset Wizard, As Initially Launched

Click on the Icon button. This will bring up the material icon selector. In the search field, type info, then click on the “info outline” icon:

Android Studio Vector Asset Wizard, Material Icon Selector
Figure 222: Android Studio Vector Asset Wizard, Material Icon Selector

Click “OK”. This will update the name of the asset to ic_info_outline_black_24dp.

Click Next, then Finish, to add that icon as an XML file in res/drawable/.

Repeat that process to add a second vector asset, this time for “help outline” – you can search on help to quickly get to this icon.

Step #2: Defining Some Options

The preview of this section was last seen in the Bermuda Triangle.

Step #3: Loading and Responding to Our Options

The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.

Step #4: Supporting Older Devices

The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.

Step #5: Trying It Out

The preview of this section is presently indisposed.

In Our Next Episode…

The preview of this section took that left turn at Albuquerque.