The Busy Coder's Guide to Android Development by Mark L. Murphy Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © 2008-2013 CommonsWare, LLC. All Rights Reserved. Printed in the United States of America. Printing History: July 2013: Version 5.0 ISBN: 978-0-9816780-0-9 The CommonsWare name and logo, “Busy Coder's Guide”, and related trade dress are trademarks of CommonsWare, LLC. All other trademarks referenced in this book are trademarks of their respective firms. The publisher and author(s) assume no responsibility for errors or omissions or for damages resulting from the use of the information contained herein. Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition Table of Contents Headings formatted in bold-italic have changed since the last version. • Preface ◦ Welcome to the Book! ...................................................................... xxix ◦ The Book’s Structure ........................................................................ xxix ◦ The Trails ................................................................................ xxx ◦ About the Updates .......................................................................... xxxiv ◦ Warescription .................................................................................. xxxv ◦ Getting Help ..................................................................................... xxxv ◦ Book Bug Bounty ............................................................................ xxxvi ◦ Source Code And Its License .......................................................... xxxvi ◦ Creative Commons and the Four-to-Free (42F) Guarantee ........ xxxvii ◦ Acknowledgments ........................................................................ xxxviii • Key Android Concepts ◦ Android Applications ............................................................................ 1 ◦ Android Devices .................................................................................... 7 ◦ Don’t Be Scared .................................................................................... 10 • Choosing Your IDE ◦ Eclipse .................................................................................................... 11 ◦ Alternative IDEs ................................................................................... 12 ◦ IDEs... And This Book ........................................................................... 13 ◦ About App Inventor .............................................................................. 13 • Tutorial #1 - Installing the Tools ◦ Step #1 - Checking Your Hardware Requirements ............................. 15 ◦ Step #2 - Setting Up Java ..................................................................... 16 ◦ Step #3 - Install the Android SDK ...................................................... 16 ◦ Step #4 - Install the ADT for Eclipse .................................................. 19 ◦ Step #5 - Install Apache Ant ............................................................... 21 ◦ Step #6 - Set Up the Emulator ............................................................ 22 ◦ Step #7 - Set Up the Device ................................................................. 29 ◦ In Our Next Episode... ......................................................................... 32 • Tutorial #2 - Creating a Stub Project ◦ About Our Tutorial Project ................................................................. 33 ◦ About the Rest of the Tutorials ........................................................... 34 ◦ About the Eclipse Instructions ........................................................... 34 ◦ Step #1: Creating the Project ............................................................... 35 ◦ Step #2: Running the Project .............................................................. 43 i Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ In Our Next Episode... ........................................................................ 46 • Contents of Android Projects ◦ Root Contents ...................................................................................... 47 ◦ The Sweat Off Your Brow ................................................................... 48 ◦ Resources ............................................................................................. 48 ◦ What You Get Out Of It ..................................................................... 49 • Inside the Manifest ◦ An Application For Your Application ................................................. 53 ◦ Specifying Versions .............................................................................. 53 ◦ Supporting Multiple Screens .............................................................. 54 ◦ Other Stuff ........................................................................................... 55 • Tutorial #3 - Changing Our Manifest ◦ Step #1: Supporting Screens ................................................................ 57 ◦ Step #2: Validating our Minimum and Target SDK Versions ........... 61 ◦ In Our Next Episode... ......................................................................... 63 • Some Words About Resources ◦ String Theory ....................................................................................... 65 ◦ Got the Picture? .................................................................................. 69 ◦ Dimensions .......................................................................................... 73 ◦ The Resource That Shall Not Be Named... Yet ................................... 75 • Tutorial #4 - Adjusting Our Resources ◦ Step #1: Changing the Name ............................................................... 77 ◦ Step #2: Changing the Icon ................................................................. 79 ◦ Step #3: Running the Result ................................................................ 87 ◦ In Our Next Episode... ........................................................................ 88 • The Theory of Widgets ◦ What Are Widgets? ............................................................................ 89 ◦ Size, Margins, and Padding ................................................................. 91 ◦ What Are Containers? ......................................................................... 91 ◦ The Absolute Positioning Anti-Pattern .............................................. 92 • The Android User Interface ◦ The Activity .......................................................................................... 95 ◦ Dissecting the Activity ....................................................................... 96 ◦ Using XML-Based Layouts .................................................................. 97 • Basic Widgets ◦ Common Concepts ............................................................................ 103 ◦ Assigning Labels ................................................................................ 105 ◦ A Commanding Button ...................................................................... 110 ◦ Fleeting Images ................................................................................... 113 ◦ Fields of Green. Or Other Colors. ..................................................... 118 ◦ More Common Concepts ................................................................... 121 ii Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ Visit the Trails! .................................................................................... 123 • Debugging Crashes ◦ Get Thee To a Stack Trace ................................................................. 126 ◦ The Case of the Confounding Class Cast ......................................... 129 ◦ Point Break ......................................................................................... 129 • LinearLayout and the Box Model ◦ Concepts and Properties .......................................................... 131 ◦ Eclipse Graphical Layout Editor ........................................................ 135 • Other Common Widgets and Containers ◦ Just a Box to Check ............................................................................. 137 ◦ Don’t Like Checkboxes? How About Toggles? ................................. 140 ◦ Turn the Radio Up ............................................................................. 142 ◦ All Things Are Relative ...................................................................... 144 ◦ Tabula Rasa ......................................................................................... 151 ◦ Scrollwork ............................................................................................ 155 ◦ Making Progress with ProgressBars ................................................. 158 ◦ Visit the Trails! ................................................................................... 159 • Tutorial #5 - Making Progress ◦ Step #1: Removing The “Hello, World” .............................................. 161 ◦ Step #2: Adding a ProgressBar .......................................................... 163 ◦ Step #3: Seeing the Results ............................................................... 165 ◦ In Our Next Episode... ....................................................................... 166 • GUI Building, Continued ◦ Making Your Selection ...................................................................... 167 ◦ Including Includes ............................................................................. 167 ◦ Wrap It Up (In a Container) ............................................................. 169 ◦ Morphing Widgets ............................................................................. 169 ◦ Preview of Coming Attractions ......................................................... 170 • AdapterViews and Adapters ◦ Adapting to the Circumstances ......................................................... 171 ◦ Lists of Naughty and Nice .................................................................. 173 ◦ Clicks versus Selections ...................................................................... 175 ◦ Spin Control ....................................................................................... 179 ◦ Grid Your Lions (Or Something Like That...) .................................. 182 ◦ Fields: Now With 35% Less Typing! ................................................. 185 ◦ Galleries, Give Or Take The Art ........................................................ 190 ◦ Customizing the Adapter ................................................................... 191 ◦ Visit the Trails! ................................................................................... 199 • The WebView Widget ◦ Role of WebView ............................................................................... 201 ◦ WebView and WebKit ....................................................................... 202 iii Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ Adding the Widget ............................................................................ 202 ◦ Loading Content Via a URL .............................................................. 203 ◦ Supporting JavaScript ........................................................................ 205 ◦ Alternatives for Loading Content .................................................... 206 ◦ Listening for Events ........................................................................... 207 ◦ Visit the Trails! ................................................................................... 210 • Defining and Using Styles ◦ Styles: DIY DRY ................................................................................... 213 ◦ Elements of Style ................................................................................ 215 ◦ Themes: Would a Style By Any Other Name... ................................ 218 • JARs and Library Projects ◦ The Dalvik VM ................................................................................... 220 ◦ The Easy Part .......................................................................... 220 ◦ The Outer Limits ................................................................................ 221 ◦ OK, So What is a Library Project? .................................................... 222 ◦ Creating a Library Project ................................................................. 222 ◦ Using a Library Project ...................................................................... 223 ◦ Limitations of Library Projects ......................................................... 224 ◦ The Android Support Package .......................................................... 225 ◦ JAR Dependency Management ......................................................... 227 • Tutorial #6 - Adding a Library ◦ Step #1: Downloading and Unpacking ActionBarSherlock .... 229 ◦ Step #2: Adding the Library to Your Project .................................... 230 ◦ In Our Next Episode... ....................................................................... 234 • Options Menus and the Action Bar ◦ Bar Hopping (a.k.a., Terminology) ................................................... 235 ◦ Yet Another History Lesson ............................................................. 240 ◦ Your Action Bar Options ................................................................... 241 ◦ Setting the Target .............................................................................. 245 ◦ Minding Narrow ............................................................................... 246 ◦ Defining the Resource ...................................................................... 246 ◦ Applying the Resource ...................................................................... 250 ◦ Responding to Events ........................................................................ 250 ◦ Attaching to Action Layouts .............................................................. 251 ◦ The Rest of the Sample Activity ........................................................ 251 ◦ Floating Action Bars .......................................................................... 259 ◦ Visit the Trails! ................................................................................... 262 • Tutorial #7 - Adding the Action Bar ◦ Step #1: Setting the Theme and Splitting the Bar ............................ 263 ◦ Step #2: Changing to SherlockFragmentActivity ............................ 265 ◦ Step #3: Defining Some Options ...................................................... 267 iv Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ Step #4: Loading and Responding to Our Options ........................ 269 ◦ Step #5: Running the Result ............................................................... 271 ◦ In Our Next Episode... ....................................................................... 273 • Android’s Process Model ◦ When Processes Are Created ............................................................ 275 ◦ BACK, HOME, and Your Process ...................................................... 276 ◦ Termination ........................................................................................ 277 ◦ Foreground Means “I Love You” ....................................................... 277 ◦ You and Your Heap ............................................................................ 278 • Activities and Their Lifecycles ◦ Creating Your Second (and Third and...) Activity .......................... 280 ◦ Warning! Contains Explicit Intents! ................................................. 285 ◦ Using Implicit Intents ....................................................................... 287 ◦ Extra! Extra! ........................................................................................ 292 ◦ Asynchronicity and Results .............................................................. 294 ◦ Schroedinger’s Activity ...................................................................... 294 ◦ Life, Death, and Your Activity ........................................................... 295 ◦ When Activities Die .......................................................................... 297 ◦ Walking Through the Lifecycle ....................................................... 298 ◦ Recycling Activities ............................................................................ 301 • Tutorial #8 - Setting Up An Activity ◦ Step #1: Creating the Stub Activity Class ......................................... 303 ◦ Step #2: Adding the Activity to the Manifest .................................. 305 ◦ Step #3: Launching Our Activity ...................................................... 307 ◦ In Our Next Episode... ....................................................................... 308 • The Tactics of Fragments ◦ The Six Questions .............................................................................. 309 ◦ Your First Fragment ................................................................. 311 ◦ The Fragment Lifecycle Methods ..................................................... 316 ◦ Your First Dynamic Fragment ............................................................ 317 ◦ Fragments and the Action Bar ........................................................... 321 ◦ Fragments Within Fragments: Just Say “Maybe” .................... 322 ◦ Fragments and Multiple Activities ................................................... 323 • Tutorial #9 - Starting Our Fragments ◦ Step #1: Copy In WebViewFragment ................................................ 325 ◦ Step #2: Examining WebViewFragment ........................................... 329 ◦ Step #3: Creating AbstractContentFragment .................................. 329 ◦ Step #4: Examining AbstractContentFragment ................................ 331 ◦ In Our Next Episode... ........................................................................ 331 • Swiping with ViewPager ◦ Swiping Design Patterns ................................................................... 333 v Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ Paging Fragments .................................................................... 334 ◦ Paging Other Stuff ............................................................................. 338 ◦ Indicators ........................................................................................... 338 ◦ Fragment-Free Paging ....................................................................... 342 ◦ Hosting ViewPager in a Fragment .................................................... 342 ◦ Pages and the Action Bar .................................................................. 344 ◦ ViewPagers and Scrollable Contents ................................................ 346 • Tutorial #10 - Rigging Up a ViewPager ◦ Step #1: Add a ViewPager to the Layout ........................................... 349 ◦ Step #2: Obtaining Our ViewPager .................................................. 350 ◦ Step #3: Creating a ContentsAdapter ................................................ 351 ◦ Step #4: Setting Up the ViewPager ................................................... 352 ◦ In Our Next Episode... ....................................................................... 353 • Resource Sets and Configurations ◦ What’s a Configuration? And How Do They Change? .................... 355 ◦ Configurations and Resource Sets .................................................... 356 ◦ Screen Size and Orientation ............................................................. 357 ◦ Coping with Complexity ................................................................... 360 ◦ Choosing The Right Resource ................................................. 361 ◦ Default Change Behavior .................................................................. 365 ◦ Your Options for Configuration Changes ........................................ 367 ◦ Blocking Rotations ............................................................................ 380 • Dealing with Threads ◦ The Main Application Thread .......................................................... 381 ◦ Getting to the Background ................................................................ 382 ◦ Asyncing Feeling ...................................................................... 383 ◦ Alternatives to AsyncTask ................................................................. 391 ◦ And Now, The Caveats ....................................................................... 393 • Requesting Permissions ◦ Mother, May I? ................................................................................... 396 ◦ New Permissions in Old Applications .............................................. 397 ◦ Permissions: Up Front Or Not At All ............................................... 398 ◦ Signature Permissions ....................................................................... 399 ◦ Requiring Permissions ....................................................................... 399 • Assets, Files, and Data Parsing ◦ Packaging Files with Your App ......................................................... 401 ◦ Files and Android .............................................................................. 403 ◦ Working with Internal Storage ........................................................ 404 ◦ Working with External Storage ........................................................ 407 ◦ Multiple User Accounts ...................................................................... 411 ◦ Linux Filesystems: You Sync, You Win .............................................. 411 vi Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ StrictMode: Avoiding Janky Code ...................................................... 413 ◦ XML Parsing Options ........................................................................ 419 ◦ JSON Parsing Options ...................................................................... 420 • Tutorial #11 - Adding Simple Content ◦ Step #1: Adding Some Content ......................................................... 421 ◦ Step #2: Create a SimpleContentFragment ...................................... 422 ◦ Step #3: Examining SimpleContentFragment ................................. 423 ◦ Step #4: Using SimpleContentFragment .......................................... 423 ◦ Step #5: Launching Our Activities, For Real This Time .................. 424 ◦ In Our Next Episode... ...................................................................... 426 • Tutorial #12 - Displaying the Book ◦ Step #1: Adding a Book ...................................................................... 427 ◦ Step #2: Defining Our Model ............................................................ 428 ◦ Step #3: Examining Our Model ........................................................ 430 ◦ Step #4: Creating a ModelFragment ................................................. 430 ◦ Step #5: Examining the ModelFragment .......................................... 433 ◦ Step #6: Supplying the Content ........................................................ 434 ◦ Step #7: Adapting the Content ......................................................... 435 ◦ Step #8: Going Home, Again ............................................................ 437 ◦ In Our Next Episode... ....................................................................... 438 • Using Preferences ◦ Getting What You Want .................................................................... 439 ◦ Stating Your Preference .................................................................... 440 ◦ Introducing PreferenceActivity ........................................................ 441 ◦ Types of Preferences .......................................................................... 453 ◦ Intents for Headers or Preferences ................................................... 456 ◦ Conditional Headers ......................................................................... 457 ◦ Option #2: Go Directly to the Fragment .......................................... 459 • Tutorial #13 - Using Some Preferences ◦ Step #1: Adding a StockPreferenceFragment .................................. 464 ◦ Step #2: Defining the Preference XML Files .................................... 465 ◦ Step #3: Creating Our PreferenceActivity ....................................... 467 ◦ Step #4: Adding To Our Action Bar ................................................. 468 ◦ Step #5: Launching the PreferenceActivity ...................................... 470 ◦ Step #6: Loading Our Preferences .................................................... 474 ◦ Step #7: Saving the Last-Read Position ............................................ 476 ◦ Step #8: Restoring the Last-Read Position ....................................... 477 ◦ Step #9: Keeping the Screen On ....................................................... 477 ◦ In Our Next Episode... ....................................................................... 478 • SQLite Databases ◦ Introducing SQLite ............................................................................ 479 vii Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ Thinking About Schemas ................................................................. 480 ◦ Start with a Helper ........................................................................... 480 ◦ Getting Data Out ............................................................................... 485 ◦ The Rest of the CRUD ............................................................. 490 ◦ Hey, What About Hibernate? .......................................................... 496 ◦ Visit the Trails! ................................................................................... 497 • Tutorial #14 - Saving Notes ◦ Step #1: Adding a DatabaseHelper .................................................. 499 ◦ Step #2: Examining DatabaseHelper ................................................ 501 ◦ Step #3: Creating a NoteFragment ................................................... 502 ◦ Step #4: Examining NoteFragment .................................................. 503 ◦ Step #5: Creating the NoteActivity ................................................... 504 ◦ Step #6: Loading and Saving Notes .................................................. 505 ◦ Step #7: Add Notes to the Action Bar ............................................. 509 ◦ Step #8: Support Deleting Notes ....................................................... 511 ◦ In Our Next Episode... ....................................................................... 519 • Internet Access ◦ DIY HTTP ................................................................................. 521 ◦ HTTP via DownloadManager ........................................................... 532 ◦ Using Third-Party JARs ............................................................ 533 ◦ SSL ............................................................................................ 533 ◦ Using HTTP Client Libraries ................................................... 540 • Intents, Intent Filters, Broadcasts, and Broadcast Receivers ◦ What’s Your Intent? ........................................................................... 559 ◦ Stating Your Intent(ions) .................................................................. 561 ◦ Responding to Implicit Intents ......................................................... 562 ◦ Requesting Implicit Intents .............................................................. 564 ◦ Broadcasts and Receivers .................................................................. 568 ◦ Example System Broadcasts .............................................................. 570 ◦ Downloading Files ............................................................................. 577 ◦ The Order of Things ......................................................................... 589 ◦ Keeping It Local ................................................................................ 590 • Tutorial #15 - Sharing Your Notes ◦ Step #1: Adding a Share Action Bar Item ......................................... 595 ◦ Step #2: Sharing the Note ................................................................ 596 ◦ Step #3: Tying Them Together .......................................................... 597 ◦ Step #4: Testing the Result ................................................................ 597 ◦ In Our Next Episode... ...................................................................... 598 • Services and the Command Pattern ◦ Why Services? ................................................................................... 599 ◦ Setting Up a Service .......................................................................... 600 viii Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ Communicating To Services ............................................................. 602 ◦ Scenario: The Music Player .............................................................. 604 ◦ Communicating From Services ........................................................ 607 ◦ Scenario: The Downloader ............................................................... 609 • Tutorial #16 - Updating the Book ◦ Step #1: Adding a Stub DownloadCheckService .............................. 616 ◦ Step #2: Tying the Service Into the Action Bar ................................ 617 ◦ Step #3: Adding a Stub DownloadCompleteReceiver ..................... 618 ◦ Step #4: Completing the DownloadCheckService .......................... 619 ◦ Step #5: Adding a Stub DownloadInstallService ............................. 623 ◦ Step #6: Completing the DownloadCompleteReceiver ................... 624 ◦ Step #7: Completing the DownloadInstallService ........................... 625 ◦ Step #8: Updating ModelFragment .................................................. 627 ◦ Step #9: Adding a BroadcastReceiver to EmPubLiteActivity .......... 630 ◦ Step #10: Discussing the Flaws .......................................................... 634 ◦ In Our Next Episode... ....................................................................... 634 • AlarmManager and the Scheduled Service Pattern ◦ Scenarios ............................................................................................ 635 ◦ Options ............................................................................................... 636 ◦ A Simple Example .............................................................................. 638 ◦ The Three Repeat Varieties .............................................................. 640 ◦ The Four Types of Alarms ................................................................. 641 ◦ When to Schedule Alarms ................................................................ 641 ◦ Get Moving, First Thing .................................................................... 643 ◦ Archetype: Scheduled Service Polling ............................................. 646 ◦ Staying Awake at Work ..................................................................... 650 ◦ Warning: Not All Android Devices Play Nice .................................. 653 ◦ Debugging Alarms ............................................................................. 654 • Tutorial #17 - Periodic Book Updates ◦ Step #1: Adding a Stub UpdateReceiver ........................................... 663 ◦ Step #2: Scheduling the Alarms ....................................................... 665 ◦ Step #3: Adding the WakefulIntentService ..................................... 666 ◦ Step #4: Using WakefulIntentService .............................................. 667 ◦ Step #5: Completing the UpdateReceiver ....................................... 668 ◦ In Our Next Episode... ...................................................................... 668 • Notifications ◦ What’s a Notification? ...................................................................... 669 ◦ Showing a Simple Notification ......................................................... 671 ◦ Notifications and Foreground Services ........................................... 676 ◦ Seeking Some Order .......................................................................... 677 ◦ Big (and Rich) Notifications ............................................................. 683 ix Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ Disabled Notifications ...................................................................... 690 • Tutorial #18 - Notifying the User ◦ Step #1: Adding the InstallReceiver .................................................. 693 ◦ Step #2: Completing the InstallReceiver ......................................... 695 ◦ In Our Next Episode... ...................................................................... 696 • Large-Screen Strategies and Tactics ◦ Objective: Maximum Gain, Minimum Pain .................................... 697 ◦ The Fragment Strategy ..................................................................... 697 ◦ Fragment Example: The List-and-Detail Pattern ................... 706 ◦ Other European Flavors .......................................................... 718 ◦ Showing More Pages ................................................................ 731 ◦ Fragment FAQs .................................................................................. 735 ◦ Screen Size and Density Tactics ....................................................... 736 ◦ Other Considerations ........................................................................ 739 • Tutorial #19 - Supporting Large Screens ◦ Step #1: Creating Our Layouts .......................................................... 743 ◦ Step #2: Loading Our Sidebar Widgets ............................................ 747 ◦ Step #3: Opening the Sidebar ........................................................... 748 ◦ Step #4: Loading Content Into the Sidebar ..................................... 749 ◦ Step #5: Removing Content From the Sidebar ................................ 752 • Backwards Compatibility Strategies and Tactics ◦ Think Forwards, Not Backwards ...................................................... 755 ◦ Aim Where You Are Going ............................................................... 757 ◦ A Target-Rich Environment .............................................................. 757 ◦ Lint: It’s Not Just For Belly Buttons .................................................. 759 ◦ A Little Help From Your Friends ...................................................... 759 ◦ Avoid the New on the Old ............................................................... 760 ◦ Testing ................................................................................................ 764 ◦ Keeping Track of Changes ................................................................. 764 • Getting Help ◦ Questions. Sometimes, With Answers. ............................................ 767 ◦ Heading to the Source ...................................................................... 768 ◦ Getting Your News Fix ...................................................................... 769 • Introducing GridLayout ◦ Prerequisites ....................................................................................... 771 ◦ Issues with the Classic Containers ................................................... 771 ◦ The New Contender: GridLayout ..................................................... 773 ◦ GridLayout and the Android Support Package ............................... 774 ◦ Eclipse and GridLayout ..................................................................... 775 ◦ Trying to Have Some Rhythm ........................................................... 775 ◦ Our Test App ...................................................................................... 776 x Subscribe to updates at https://commonsware.com Special Creative Commons BY-NC-SA 4.0 License Edition ◦ Replacing the Classics ....................................................................... 778 ◦ Implicit Rows and Columns .............................................................. 785 ◦ Row and Column Spans .................................................................... 787 ◦ Should You Use GridLayout? ............................................................ 791 • Dialogs and DialogFragments ◦ Prerequisites ....................................................................................... 793 ◦ DatePickerDialog and TimePickerDialog ........................................ 793 ◦ AlertDialog ........................................................................................ 799 ◦ DialogFragments ............................................................................... 800 ◦ DialogFragment: The Other Flavor ................................................. 804 ◦ Dialogs: Modal, Not Blocking ........................................................... 805 • Advanced ListViews ◦ Prerequisites ...................................................................................... 807 ◦ Multiple Row Types, and Self Inflation ........................................... 807 ◦ Choice Modes and the Activated Style ............................................. 813 ◦ Custom Mutable Row Contents ........................................................ 814 ◦ From Head To Toe ............................................................................. 820 • Action Bar Navigation ◦ Prerequisites ....................................................................................... 825 ◦ List Navigation ................................................................................... 825 ◦ Tabs (And Sometimes List) Navigation ........................................... 830 ◦ Custom Navigation ............................................................................ 836 • Action Modes and Context Menus ◦ Prerequisites ....................................................................................... 838 ◦ Another Wee Spot O’ History ........................................................... 838 ◦ Manual Action Modes ....................................................................... 839 ◦ Multiple-Modal-Choice Action Modes .................................... 844 ◦ Split Action Modes ........................................................................... 849 ◦ What Came Before: Context Menus ................................................. 851 • Advanced Uses of WebView ◦ Prerequisites ....................................................................................... 855 ◦ Friends with Benefits ......................................................................... 855 ◦ Turnabout is Fair Play ........................................................................ 861 ◦ Navigating the Waters ....................................................................... 865 ◦ Settings, Preferences, and Options (Oh, My!) ................................. 865 • T