In this chapter, you created an Address Book app that enables users to add, view, edit and delete contact information that’s stored in a SQLite database. You defined common GUI component attribute–value pairs as XML style
resources, then applied the styles to all components that share those values by using the components’ style
attribute. You added a border to a TextView
by specifying a Drawable
as the value for the TextView
’s android:background
attribute and you created a custom Drawable
using an XML representation of a shape
. You also used Android standard icons to enhance the visual appearance of the app’s menu items.
When an Fragment
’s primary task is to display a scrollable list of items, you learned that you can extend class ListFragment
to create a Fragment
that displays a ListView
in its default layout. You used this to display the contacts stored in the app’s database. You bound data to the ListView
via a CursorAdapter
that displayed the results of a database query.
In this app’s Activity
, you used FragmentTransaction
s to add Fragment
s to and replace Fragments
in the GUI dynamically. You also used the Fragment
back stack to support the back button for returning to a previously displayed Fragment
and to allow the app’s Activity
to programmatically return to previous Fragment
s.
We demonstrated how to communicate data between Fragment
s and a host Activity
or the Activity
’s other Fragment
s via interfaces of callback methods that are implemented by the host Activity
. You also used Bundle
s to pass arguments to Fragment
s.
You used a subclass of SQLiteOpenHelper
to simplify creating the database and to obtain a SQLiteDatabase
object for manipulating a database’s contents. You processed query results via a Cursor
. You used subclasses of AsyncTask
to perform database tasks outside the GUI thread and return results to the GUI thread. This allowed you to take advantage of Android’s threading capabilities without directly creating and manipulating threads.
In Chapter 9, we discuss the business side of Android app development. You’ll see how to prepare your app for submission to Google Play, including making icons. We’ll discuss how to test your apps on devices and publish them on Google Play. We discuss the characteristics of great apps and the Android design guidelines to follow. We provide tips for pricing and marketing your app. We also review the benefits of offering your app for free to drive sales of other products, such as a more feature-rich version of the app or premium content. We show how to use Google Play to track app sales, payments and more.