Book description
What will you learn from this book?
If you have an idea for a killer Android app, this fully revised and updated edition will help you build your first working application in a jiffy. You’ll learn hands-on how to structure your app, design flexible and interactive interfaces, run services in the background, make your app work on various smartphones and tablets, and much more. It’s like having an experienced Android developer sitting right next to you! All you need to get started is some Java know-how.
Why does this book look so different?
Based on the latest research in cognitive science and learning theory, Head First Android Development uses a visually rich format to engage your mind, rather than a text-heavy approach that puts you to sleep. Why waste your time struggling with new concepts? This multi-sensory learning experience is designed for the way your brain really works.
Publisher resources
Table of contents
- Authors of Head First Android Development
- How to use this Book: Intro
- The technical review team
- Acknowledgments
- O’Reilly Safari ®
-
1. Getting Started: Diving In
- Welcome to Androidville
- The Android platform dissected
- Here’s what we’re going to do
- Your development environment
- Install Android Studio
- Build a basic app
- How to build the app
- How to build the app (continued)
- How to build the app (continued)
- Activities and layouts from 50,000 feet
- How to build the app (continued)
- How to build the app (continued)
- You’ve just created your first Android app
- Android Studio creates a complete folder structure for you
- Useful files in your project
- Edit code with the Android Studio editors
- Run the app in the Android emulator
- Create an Android Virtual Device
- Creating an AVD (continued)
- Creating an AVD (continued)
- Run the app in the emulator
- You can watch progress in the console
- Test drive
- What just happened?
- Refine the app
- What’s in the layout?
- activity_main.xml has two elements
- Update the text displayed in the layout
- Take the app for a test drive
- Chapter 1 Your Android Toolbox
-
2. Building Interactive Apps: Apps That Do Something
- Let’s build a Beer Adviser app
- Here’s what we’re going to do
- Create the project
- We’ve created a default activity and layout
- A closer look at the design editor
- Add a button using the design editor
- activity_find_beer.xml has a new button
- A closer look at the layout code
- A closer look at the layout code (continued)
- Changes to the XML...
- ... are reflected in the design editor
- Let’s take the app for a test drive
- Hardcoding text makes localization hard
- Create the String resource
- Use the String resource in your layout
- The code for activity_find_beer.xml
- Time for a test drive
- Add values to the spinner
- Add the string-array to strings.xml
- Test drive the spinner
- We need to make the button do something
- Make the button call a method
- What activity code looks like
- Add an onClickFindBeer() method to the activity
- onClickFindBeer() needs to do something
- Once you have a view, you can access its methods
- Update the activity code
- The first version of the activity
- What the code does
- Test drive the changes
- Build the custom Java class
- Enhance the activity to call the custom Java class so that we can get REAL advice
- Activity code version 2
- What happens when you run the code
- Test drive your app
- Chapter 2 Your Android Toolbox
-
3. Multiple Activities and Intents: State Your Intent
- Apps can contain more than one activity
- Here’s the app structure
- Get started: create the project
- Update the layout
- Update strings.xml...
- Create the second activity and layout
- What just happened?
- Welcome to the Android manifest file
- Every activity needs to be declared
- An intent is a type of message
- Use an intent to start the second activity
- What happens when you run the app
- The story continues...
- Test drive the app
- Pass text to a second activity
- Update the text view properties
- putExtra() puts extra info in an intent
- Update the CreateMessageActivity code
- Get ReceiveMessageActivity to use the information in the intent
- What happens when the user clicks the Send Message button
- Test drive the app
- We can change the app to send messages to other people
- How Android apps work
- But we don’t know what apps are on the user’s device
- Create an intent that specifies an action
- Change the intent to use an action
- What happens when the code runs
- The story continues...
- The intent filter tells Android which activities can handle which actions
- How Android uses the intent filter
- You need to run your app on a REAL device
- Running your app on a real device (continued)
- Test drive the app
- What if you ALWAYS want your users to choose an activity?
- What happens when you call createChooser()
- The story continues...
- Change the code to create a chooser
- Test drive the app
- If you have NO matching activities
- Chapter 3 Your Android Toolbox
-
4. The Activity Lifecycle: Being an Activity
- How do activities really work?
- The Stopwatch app
- Add String resources
- The layout code (continued)
- How the activity code will work
- Add code for the buttons
- The runTimer() method
- Handlers allow you to schedule code
- The full runTimer() code
- The full StopwatchActivity code
- The activity code (continued)
- What happens when you run the app
- The story continues
- Test drive the app
- What just happened?
- Rotating the screen changes the device configuration
- The states of an activity
- The activity lifecycle: from create to destroy
- Your activity inherits the lifecycle methods
- Save the current state...
- ... then restore the state in onCreate()
- The updated StopwatchActivity code
- What happens when you run the app
- The story continues
- Test drive the app
- There’s more to an activity’s life than create and destroy
- The activity lifecycle: the visible lifetime
- We need to implement two more lifecycle methods
- The updated StopwatchActivity code
- What happens when you run the app
- Test drive the app
- What if an app is only partially visible?
- The activity lifecycle: the foreground lifetime
- Stop the stopwatch if the activity’s paused
- Implement the onPause() and onResume() methods
- The complete StopwatchActivity code
- The activity code (continued)
- The activity code (continued)
- What happens when you run the app
- Test drive the app
- Your handy guide to the lifecycle methods
- Chapter 4 Your Android Toolbox
-
5. Views and View Groups: Enjoy the View
- Your user interface is made up of layouts and GUI components
- LinearLayout displays views in a single row or column
- Orientation is vertical or horizontal
- Padding adds space
- Add a dimension resource file for consistent padding across layouts
- A linear layout displays views in the order they appear in the layout XML
- Use margins to add distance between views
- Let’s change up a basic linear layout
- Here’s the starting point for the linear layout
- Make a view streeeeetch by adding weight
- Adding weight to one view
- Adding weight to multiple views
- Gravity controls the position of a view’s contents
- Test drive
- Values you can use with the android:gravity attribute
- layout_gravity controls the position of a view within a layout
- More values you can use with the android:layout_gravity attribute
- The full linear layout code
- LinearLayout: a summary
- Frame layouts stack their views
- Add an image to your project
- A frame layout stacks views in the order they appear in the layout XML
- You can nest layouts
- The full code to nest a layout
- FrameLayout: a summary
- Layouts and GUI components have a lot in common
- GUI components are a type of View
- What being a view buys you
- A layout is really a hierarchy of Views
- Playing with views
- Text view
- Editable text view
- Button
- Toggle button
- Switch
- Checkboxes
- Checkboxes (continued)
- Radio buttons
- Radio buttons (continued)
- Spinner
- Image view
- Image view: the layout XML
- Adding images to buttons
- Image button
- Scroll view
- Toasts
- Chapter 5 Your Android Toolbox
-
6. Constraint Layouts: Put Things in Their Place
- Nested layouts can be inefficient
- Introducing the constraint layout
- Make sure your project includes the Constraint Layout Library
- Add the String resources to strings.xml
- Use the blueprint tool
- Position views using constraints
- Add a vertical constraint
- Changes to the blueprint are reflected in the XML
- How to center views
- Adjust a view’s position by updating its bias
- How to change a view’s size
- How to align views
- Let’s build a real layout
- First, add the top line of views
- The Infer Constraints feature guesses which constraints to add
- Add the next line to the blueprint...
- Finally, add a view for the message
- Test drive the app
- Chapter 6 Your Android Toolbox
-
7. List Views and Adapters: Getting Organized
- Every app starts with ideas
- Organize your ideas: top-level, category, and detail/edit activities
- Navigating through the activities
- Use list views to navigate to data
- We’re going to build part of the Starbuzz app
- The drink detail activity
- The Starbuzz app structure
- Here’s what we’re going to do
- The Drink class
- The image files
- The top-level layout contains an image and a list
- Use a list view to display the list of options
- The full top-level layout code
- Test drive
- Get list views to respond to clicks with a listener
- Set the listener to the list view
- TopLevelActivity.java (continued)
- Where we’ve got to
- A category activity displays the data for a single category
- Update activity_drink_category.xml
- For nonstatic data, use an adapter
- Connect list views to arrays with an array adapter
- Add the array adapter to DrinkCategoryActivity
- What happens when you run the code
- Test drive the app
- App review: where we are
- How we handled clicks in TopLevelActivity
- Pass the ID of the item that was clicked by adding it to an intent
- The full DrinkCategoryActivity code
- A detail activity displays data for a single record
- Retrieve data from the intent
- Update the views with the data
- The DrinkActivity code
- What happens when you run the app
- The story continues
- Test drive the app
- Chapter 7 Your Android Toolbox
-
8. Support Libraries and App Bars: Taking Shortcuts
- Great apps have a clear structure
- Different types of navigation
- Here’s what we’re going to do
- Add an app bar by applying a theme
- Support libraries allow you to use new features in older versions of Android
- Create the Pizza app
- Add the v7 AppCompat Support Library
- AppCompatActivity lets you use AppCompat themes
- MainActivity needs to be an AppCompatActivity
- AndroidManifest.xml can change your app bar’s appearance
- How to apply a theme
- Define styles in a style resource file
- Theme gallery
- Customize the look of your app
- Define colors in a color resource file
- The code for activity_main.xml
- Test drive the app
- ActionBar vs. Toolbar
- 1. Add the AppCompat Support Library
- 2. Extend the AppCompatActivity class
- 3. Remove the app bar
- 4. Add a toolbar to the layout
- Add the toolbar to the layout...
- ... or define the toolbar as a separate layout
- Include the toolbar in the activity’s layout
- 5. Set the toolbar as the activity’s app bar
- Test drive the app
- Add actions to the app bar
- Update activity_order.xml
- Update OrderActivity.java
- Change the app bar text by adding a label
- The code for AndroidManifest.xml
- 1. Add the action’s resources
- 2. Create the menu resource file
- Control the action’s appearance
- 3. Add the menu to the app bar with the onCreateOptionsMenu() method
- 4. React to action item clicks with the onOptionsItemSelected() method
- The full MainActivity.java code
- Test drive the app
- Enable Up navigation
- Set an activity’s parent
- Adding the Up button
- Test drive the app
- Sharing content on the app bar
- Add a share action provider to menu_main.xml
- Specify the content with an intent
- The full MainActivity.java code
- The MainActivity.java code (continued)
- Test drive the app
- Chapter 8 Your Android Toolbox
-
9. Fragments: Make It Modular
- Your app needs to look great on ALL devices
- Your app may need to behave differently too
- Fragments allow you to reuse code
- The phone version of the app
- Here’s what we’re going to do
- Create the project and activities
- Add a button to MainActivity’s layout
- Make the button respond to clicks
- How to add a fragment to your project
- What fragment code looks like
- The fragment’s onCreateView() method
- Fragment layout code looks just like activity layout code
- Add a fragment to an activity’s layout
- Simplify the layout
- Support Library fragments need activities that extend FragmentActivity
- What the code does
- The story continues
- Test drive the app
- Get the fragment and activity to interact
- The Workout class
- Pass the workout ID to the fragment
- Use the fragment manager to manage fragments
- Get the activity to set the workout ID
- Activity states revisited
- The fragment lifecycle
- Fragments inherit lifecycle methods
- Set the view’s values in the fragment’s onStart() method
- What happens when the code runs
- The story continues
- Test drive the app
- Where we’ve got to
- We need to create a fragment with a list
- A list fragment is a fragment that contains only a list
- How to create a list fragment
- Adapters revisited
- Our previous array adapter
- The updated WorkoutListFragment code
- Display WorkoutListFragment in the MainActivity layout
- The code for activity_main.xml
- What happens when the code runs
- The story continues
- Test drive the app
- Connect the list to the detail
- We need to decouple the fragment by using an interface
- The code for WorkoutListFragment.java
- MainActivity needs to implement the interface
- DetailActivity needs to pass the ID to WorkoutDetailFragment
- What happens when the code runs
- The story continues...
- Test drive the app
- Chapter 9 Your Android Toolbox
-
10. Fragments for Larger Interfaces: Different Size, Different Interface
- The Workout app looks the same on a phone and a tablet
- Designing for larger interfaces
- The phone version of the app
- The tablet version of the app
- Here’s what we’re going to do
- Create a tablet AVD
- Creating a tablet AVD (continued)
- Creating a tablet AVD (continued)
- Put screen-specific resources in screen-specific folders
- The different folder options
- Tablets use layouts in the layout-large folder
- The layout-large version of the layout needs to display two fragments
- What the updated code does
- Test drive the app
- We need to change the itemClicked() code
- You want fragments to work with the Back button
- Welcome to the back stack
- Back stack transactions don’t have to be activities
- Use a frame layout to replace fragments programmatically
- Use layout differences to tell which layout the device is using
- The revised MainActivity code
- Using fragment transactions
- The updated MainActivity code
- What happens when the code runs
- The story continues...
- Test drive the app
- Rotating the tablet breaks the app
- Saving an activity’s state (revisited)
- Save the fragment’s state...
- The updated code for WorkoutDetailFragment.java
- WorkoutDetailFragment.java (continued)
- Test drive the app
- Chapter 10 Your Android Toolbox
-
11. Dynamic Fragments: Nesting Fragments
- Adding dynamic fragments
- Here’s what we’re going to do
- The new version of the app
- Create TempActivity
- TempActivity needs to extend AppCompatActivity
- Fragments and activities have similar lifecycles...
- The StopwatchFragment.java code
- StopwatchFragment.java (continued)
- StopwatchFragment.java (continued)
- The StopwatchFragment layout
- The StopwatchFragment layout (continued)
- Add StopwatchFragment to TempActivity’s layout
- Test drive the app
- The app crashes if you click on a button
- Let’s look at the StopwatchFragment layout code
- The onClick attribute calls methods in the activity, not the fragment
- 1. Remove the onClick attributes from the fragment’s layout
- 2. Change the onClick... method signatures
- 3. Make the fragment implement OnClickListener
- Attach the OnClickListener to the buttons
- The StopwatchFragment code
- The StopwatchFragment code (continued)
- The StopwatchFragment code (continued)
- Test drive the app
- Rotating the device resets the stopwatch
- Use <fragment> for static fragments...
- Change activity_temp.xml to use a FrameLayout
- The full code for TempActivity.java
- Test drive the app
- Add the stopwatch to WorkoutDetailFragment
- What we’re going to do
- Add a FrameLayout where the fragment should appear
- So far, we’ve only used fragment transactions in activities
- Using getFragmentManager() creates extra transactions on the back stack
- Using getChildFragmentManager() creates nested transactions instead
- What getChildFragmentManager() fragment transaction code looks like
- The full WorkoutDetailFragment.java code
- The full code (continued)
- Test drive the app
- Test drive (continued)
- Chapter 11 Your Android Toolbox
-
12. Design Support Library: Swipe Right
- The Bits and Pizzas app revisited
- The app structure
- Here’s what we’re going to do
- Create TopFragment
- Create PizzaFragment
- Create PastaFragment
- Create StoresFragment
- Use a view pager to swipe through fragments
- Add a view pager to MainActivity’s layout
- Tell a view pager about its pages using a fragment pager adapter
- The code for our fragment pager adapter
- Attach the fragment pager adapter to the view pager
- The full code for MainActivity.java
- The MainActivity.java code (continued)
- The MainActivity.java code (continued)
- Test drive the app
- Add tab navigation to MainActivity
- How to add tabs to your layout
- Add tabs to MainActivity’s layout
- Link the tab layout to the view pager
- The full code for MainActivity.java
- The MainActivity.java code (continued)
- The MainActivity.java code (continued)
- Test drive the app
- The Design Support Library helps you implement material design
- Here’s what we’ll do
- Make the toolbar respond to scrolls
- Add a coordinator layout to MainActivity’s layout
- How to coordinate scroll behavior
- The code to enable to toolbar to scroll
- Add scrollable content to TopFragment
- Use a nested scroll view to make layout content scrollable
- How we’ll structure TopFragment’s layout
- The full code for fragment_top.xml
- Test drive the app
- Add a collapsing toolbar to OrderActivity
- How to create a plain collapsing toolbar
- The full code to add a collapsing toolbar to activity_order.xml
- The activity_order.xml code (continued)
- Test drive the app
- How to add an image to a collapsing toolbar
- The updated code for activity_order.xml
- The activity_order.xml code (continued)
- Test drive the app
- FABs and snackbars
- Add the icon for the FAB
- The updated code for activity_order.xml
- The activity_order.xml code (continued)
- How to create a snackbar
- The full code for OrderActivity.java
- Test drive the app
- Chapter 12 Your Android Toolbox
-
13. Recycler Views and Card Views: Get Recycling
- There’s still work to do on the Bits and Pizzas app
- Recycler views from 10,000 feet
- Here’s what we’re going to do
- Add the pizza data
- Display the pizza data in a card
- How to create a card view
- The full card_captioned_image.xml code
- How our recycler view adapter will work
- Add a recycler view adapter
- Tell the adapter what data it should work with...
- Define the adapter’s view holder
- Override the onCreateViewHolder() method
- Add the data to the card views
- The full code for CaptionedImagesAdapter.java
- The full CaptionedImagesAdapter.java code (continued)
- Create the recycler view
- Add the RecyclerView to PizzaFragment’s layout
- The full PizzaFragment.java code
- A recycler view uses a layout manager to arrange its views
- Specify the layout manager
- The full PizzaFragment.java code
- What happens when the code runs
- The story continues
- Test drive the app
- Make the recycler view respond to clicks
- Create PizzaDetailActivity
- What PizzaDetailActivity needs to do
- The code for PizzaDetailActivity.java
- Get a recycler view to respond to clicks
- You can listen for view events from the adapter
- Keep your adapters reusable
- Add the interface to the adapter
- The CaptionedImagesAdapter.java code (continued)
- Implement the listener in PizzaFragment.java
- The PizzaFragment.java code (continued)
- Test drive the app
- Chapter 13 Your Android Toolbox
-
14. Navigation Drawers: Going Places
- Tab layouts allow easy navigation...
- ... but navigation drawers let you show more options
- We’re going to create a navigation drawer for a new email app
- Navigation drawers deconstructed
- Here’s what we’re going to do
- Create the CatChat project
- Create InboxFragment
- Create DraftsFragment
- Create SentItemsFragment
- Create TrashFragment
- Create a toolbar layout
- Update the app’s theme
- Create HelpActivity
- Create FeedbackActivity
- We need to build a navigation drawer
- Create the navigation drawer’s header
- The full nav_header.xml code
- The drawer gets its options from a menu
- Add items in the order you want them to appear in the drawer
- How to group items together
- We’ll use a group for the first section
- Add the support section as a submenu
- The full menu_nav.xml code
- How to create a navigation drawer
- The full code for activity_main.xml
- Add InboxFragment to MainActivity’s frame layout
- Test drive the app
- What the activity code needs to do
- Add a drawer toggle
- Respond to the user clicking items in the drawer
- Implement the onNavigationItemSelected() method
- Close the drawer when the user presses the Back button
- The full MainActivity.java code
- MainActivity.java (continued)
- MainActivity.java (continued)
- Test drive the app
- Chapter 14 Your Android Toolbox
-
15. SQLite Databases: Fire Up the Database
- Back to Starbuzz
- Android uses SQLite databases to persist data
- Android comes with SQLite classes
- The current Starbuzz app structure
- Let’s change the app to use a database
- The SQLite helper manages your database
- Create the SQLite helper
- Specify the database
- Inside a SQLite database
- You create tables using Structured Query Language (SQL)
- Insert data using the insert() method
- Insert multiple records
- The StarbuzzDatabaseHelper code
- What the SQLite helper code does
- What if you need to make changes to the database?
- SQLite databases have a version number
- What happens when you change the version number
- Upgrade your database with onUpgrade()
- Downgrade your database with onDowngrade()
- Let’s upgrade the database
- The SQLite helper code (continued)
- Upgrade an existing database
- Update records with the update() method
- Apply conditions to multiple columns
- Change the database structure
- Delete tables by dropping them
- The full SQLite helper code
- The SQLite helper code (continued)
- What happens when the code runs
- Chapter 15 Your Android Toolbox
-
16. Basic Cursors: Getting Data Out
- The story so far...
- The new Starbuzz app structure
- What we’ll do to change DrinkActivity to use the Starbuzz database
- The current DrinkActivity code
- Get a reference to the database
- Get data from the database with a cursor
- Return all the records from a table
- Return records in a particular order
- Return selected records
- The DrinkActivity code so far
- To read a record from a cursor, you first need to navigate to it
- Navigate cursors
- Get cursor values
- Finally, close the cursor and the database
- The DrinkActivity code
- The DrinkActivity code (continued)
- What we’ve done so far
- What we’ll do to change DrinkCategoryActivity to use the Starbuzz database
- The current DrinkCategoryActivity code
- Get a reference to the Starbuzz database...
- ... then create a cursor that returns the drinks
- How do we replace the array data in the list view?
- A simple cursor adapter maps cursor data to views
- How to use a simple cursor adapter
- Close the cursor and database
- The story continues
- The revised code for DrinkCategoryActivity
- The DrinkCategoryActivity code (continued)
- Test drive the app
- Chapter 16 Your Android Toolbox
-
17. Cursors and Asynctasks: Staying in the Background
- We want our Starbuzz app to update database data
- We’ll update DrinkActivity first
- Add a checkbox to DrinkActivity’s layout
- Display the value of the FAVORITE column
- Respond to clicks to update the database
- The full DrinkActivity.java code
- DrinkActivity.java (continued)
- DrinkActivity.java (continued)
- Test drive the app
- Display favorites in TopLevelActivity
- Display the favorite drinks in activity_top_level.xml
- Refactor TopLevelActivity.java
- What changes are needed for TopLevelActivity.java
- Ready Bake Code
- The new TopLevelActivity.java code
- The TopLevelActivity.java code (continued)
- The TopLevelActivity.java code (continued)
- Test drive the app
- Cursors don’t automatically refresh
- Change the cursor with changeCursor()
- The revised TopLevelActivity.java code
- The TopLevelActivity.java code (continued)
- The TopLevelActivity.java code (continued)
- Test drive the app
- Databases can make your app go in sloooow-moooo....
- What code goes on which thread?
- AsyncTask performs asynchronous tasks
- The onPreExecute() method
- The doInBackground() method
- The onProgressUpdate() method
- The onPostExecute() method
- The AsyncTask class parameters
- The full UpdateDrinkTask class
- Execute the AsyncTask...
- ... in DrinkActivity’s onFavoritesClicked() method
- The full DrinkActivity.java code
- The full DrinkActivity.java code (continued)
- The full DrinkActivity.java code (continued)
- The full DrinkActivity.java code (continued)
- Test drive the app
- Chapter 17 Your Android Toolbox
- A summary of the AsyncTask steps
-
18. Started Services: At Your Service
- Services work in the background
- We’ll create a STARTED service
- Use the IntentService class to create a basic started service
- How to log messages
- The full DelayedMessageService code
- You declare services in AndroidManifest.xml
- Add a button to activity_main.xml
- You start a service using startService()
- What happens when you run the app
- Test drive the app
- The states of a started service
- The started service lifecycle: from create to destroy
- Your service inherits the lifecycle methods
- Android has a built-in notification service
- We’ll use notifications from the AppCompat Support Library
- First create a notification builder
- Add an action to tell the notification which activity to start when clicked
- Issue the notification using the built-in notification service
- The full code for DelayedMessageService.java
- The DelayedMessageService.java code (continued)
- What happens when you run the code
- The story continues
- Test drive the app
- Chapter 18 Your Android Toolbox
-
19. Bound Services and Permissions: Bound Together
- Bound services are bound to other components
- Here’s what we’re going to do
- Create a new service
- Implement a binder
- Add a getDistance() method to the service
- Update MainActivity’s layout
- What MainActivity needs to do
- Create a ServiceConnection
- The onServiceConnected() method
- The onServiceDisconnected() method
- Use bindService() to bind the service
- Use unbindService() to unbind from the service
- Call OdometerService’s getDistance() method
- The full MainActivity.java code
- The MainActivity.java code (continued)
- What happens when you run the code
- The story continues
- The story continues
- Test drive the app
- The states of a bound service
- The bound service lifecycle: from create to destroy
- We’ll use Android’s Location Services to return the distance traveled
- Add the AppCompat Support Library
- Declare the permissions you need
- Add a location listener to OdometerService
- We need a location manager and location provider
- Request location updates...
- ... but first check that your app has permission
- Here’s the updated OdometerService code
- Calculate the distance traveled
- Return the miles traveled
- Stop the listener getting location updates
- The full OdometerService.java code
- The OdometerService.java code (continued)
- The OdometerService.java code (continued)
- Test drive the app
- Get the app to request permission
- Check permissions at runtime
- Check for Location Services permissions in MainActivity’s onStart() method
- Check the user’s response to the permission request
- Issue a notification if we’re denied permission
- Add notification code to onRequestPermissionsResults()
- The notification code (continued)
- The full code for MainActivity.java
- The MainActivity.java code (continued)
- The MainActivity.java code (continued)
- Test drive the app
- Chapter 19 Your Android Toolbox
- Leaving town...
- It’s been great having you here in Androidville
-
A. Relative and Grid Layouts: Meet the Relatives
- A relative layout displays views in relative positions
- Positioning views to the left or right
- Attributes for positioning views relative to the parent layout
- Positioning views relative to other views
- Attributes for positioning views relative to other views
- A grid layout displays views in a grid
- Adding views to the grid layout
- Let’s create a new grid layout
- We’ll start with a sketch
- Row 0: add views to specific rows and columns
- Row 1: make a view span multiple columns
- Row 2: make a view span multiple columns
- The full code for the grid layout
- The grid layout code (continued)
- B. Gradle: The Gradle Build Tool
- C. Art: The Android Runtime
- D. ADB: The Android Debug Bridge
- E. The Android Emulator: Speeding Things Up
- F. Leftovers: The Top Ten Things (we didn’t cover)
- Index
Product information
- Title: Head First Android Development, 2nd Edition
- Author(s):
- Release date: August 2017
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781491974056
You might also like
book
Head First Android Development, 3rd Edition
What will you learn from this book? If you have an idea for a killer Android …
book
Android Programming: The Big Nerd Ranch Guide, 5th Edition
Android Programming: The Big Nerd Ranch Guide is an introductory Android book for programmers with Kotlin …
book
Learning Java, 5th Edition
If you're new to Java—or new to programming—this best-selling book will guide you through the language …
book
Head First Java, 2nd Edition
Learning a complex new language is no easy task especially when it s an object-oriented computer …