Creating Dynamic UI with Android Fragments
By Jim Wilson
()
About this ebook
Jim Wilson
Jim L. Wilson (DMin, Golden Gate Baptist Theological Seminary) is professor of leadership formation and director of the Doctor of Ministry program at Gateway Seminary. He has authored many books, including Future Church: Ministry in a Post-Seeker Age.
Read more from Jim Wilson
How to Be Free From Bitterness Rating: 5 out of 5 stars5/5Launch Pad UK: Britain and the Cuban Missile Crisis Rating: 0 out of 5 stars0 ratingsA Guide to Theological Reflection: A Fresh Approach for Practical Ministry Courses and Theological Field Education Rating: 0 out of 5 stars0 ratingsChokehold: Pro Wrestling's Real Mayhem Outside the Ring Rating: 0 out of 5 stars0 ratingsThe Birds of Ireland Rating: 5 out of 5 stars5/5Firebrand's Lady Rating: 4 out of 5 stars4/5Principles of War: A Handbook on Strategic Evangelism Rating: 0 out of 5 stars0 ratingsBritain on the Brink: The Cold War's Most Dangerous Weekend, 27–28 October 1962 Rating: 4 out of 5 stars4/5How to Be a Responsible Man Rating: 0 out of 5 stars0 ratingsRepentance and Restitution (The Missing Ingredient in Repentance) Rating: 0 out of 5 stars0 ratingsHow to Be Free from Anxiety Rating: 4 out of 5 stars4/5Dead and Alive: Obedience and the New Man Rating: 0 out of 5 stars0 ratingsNazi Princess: Hitler, Lord Rothermere and Princess Stephanie von Hohenlohe Rating: 4 out of 5 stars4/5How to Maintain Joy in Your Life Rating: 0 out of 5 stars0 ratingsHow to Be Free Rating: 0 out of 5 stars0 ratingsAnswered Prayer: The Faithfulness of God Made Manifest Rating: 0 out of 5 stars0 ratingsI Have Given Them the Glory: Thoughts on Christian Unity Rating: 0 out of 5 stars0 ratingsAssurances of Salvation Rating: 0 out of 5 stars0 ratingsGrace Upon Grace: Nine Decades of Stories From a Farm Boy, Midshipman, Officer, and Evangelist Rating: 0 out of 5 stars0 ratingsSaved from Being Good: The Testimony of Jim Wilson Rating: 0 out of 5 stars0 ratingsIreland's Garden Birds: A Guide to Attracting and Identifying Garden Birds Rating: 0 out of 5 stars0 ratingsCreating Dynamic UIs with Android Fragments - Second Edition Rating: 0 out of 5 stars0 ratingsWisdom Not Knowledge: Thoughts on Christian Counseling Rating: 0 out of 5 stars0 ratingsHow to Be Free from Depression Rating: 0 out of 5 stars0 ratings
Related to Creating Dynamic UI with Android Fragments
Related ebooks
Creating Dynamic UIs with Android Fragments - Second Edition Rating: 0 out of 5 stars0 ratingsSwift 2 Design Patterns Rating: 0 out of 5 stars0 ratingsjQuery UI 1.7: The User Interface Library for jQuery Rating: 0 out of 5 stars0 ratingsMobile Web Performance Optimization Rating: 0 out of 5 stars0 ratingsResponsive Media in HTML5 Rating: 0 out of 5 stars0 ratingsAndroid Wearable Programming Rating: 0 out of 5 stars0 ratingsA UX Designers Guide to Coding: Merging the Worlds of Design and Development Rating: 0 out of 5 stars0 ratingsResponsive Design High Performance Rating: 0 out of 5 stars0 ratingsjQuery Mobile Web Development Essentials - Third Edition Rating: 0 out of 5 stars0 ratingsLearning Android Game Development Rating: 0 out of 5 stars0 ratingsMastering Ninject for Dependency Injection Rating: 0 out of 5 stars0 ratingsJavaScript Mobile Application Development Rating: 0 out of 5 stars0 ratingsLearning Node.js for Mobile Application Development Rating: 0 out of 5 stars0 ratingsBeginning DotNetNuke Skinning and Design Rating: 0 out of 5 stars0 ratingsAndroid Application Development with Maven Rating: 0 out of 5 stars0 ratingsInstant Responsive Web Design Rating: 5 out of 5 stars5/5Mastering Android NDK Rating: 0 out of 5 stars0 ratingsHTML5 for Flash Developers Rating: 5 out of 5 stars5/5Augmented Reality for Android Application Development Rating: 0 out of 5 stars0 ratingsjQuery 1.3 with PHP Rating: 0 out of 5 stars0 ratingsGradle for Android Rating: 0 out of 5 stars0 ratingsJavaScript for Modern Web Development: Building a Web Application Using HTML, CSS, and JavaScript Rating: 0 out of 5 stars0 ratingsAndroid Application Programming with OpenCV Rating: 3 out of 5 stars3/5WebGL Hotshot Rating: 0 out of 5 stars0 ratingsFundamentals of Android App Development: Android Development for Beginners to Learn Android Technology, SQLite, Firebase and Unity Rating: 0 out of 5 stars0 ratingsMy First Mobile App for Students: A comprehensive guide to Android app development for beginners (English Edition) Rating: 0 out of 5 stars0 ratingsUnity Virtual Reality Projects Rating: 0 out of 5 stars0 ratingsCloning Internet Applications with Ruby Rating: 5 out of 5 stars5/5Adobe Edge Quickstart Guide Rating: 0 out of 5 stars0 ratings
Internet & Web For You
Podcasting For Dummies Rating: 4 out of 5 stars4/5More Porn - Faster!: 50 Tips & Tools for Faster and More Efficient Porn Browsing Rating: 3 out of 5 stars3/5The Mega Box: The Ultimate Guide to the Best Free Resources on the Internet Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Cybersecurity For Dummies Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5The Logo Brainstorm Book: A Comprehensive Guide for Exploring Design Directions Rating: 4 out of 5 stars4/5The Designer's Web Handbook: What You Need to Know to Create for the Web Rating: 0 out of 5 stars0 ratingsThe $1,000,000 Web Designer Guide: A Practical Guide for Wealth and Freedom as an Online Freelancer Rating: 5 out of 5 stars5/5Six Figure Blogging Blueprint Rating: 5 out of 5 stars5/5Coding For Dummies Rating: 5 out of 5 stars5/5The Digital Marketing Handbook: A Step-By-Step Guide to Creating Websites That Sell Rating: 5 out of 5 stars5/5Wireless Hacking 101 Rating: 4 out of 5 stars4/5Tor and the Dark Art of Anonymity Rating: 5 out of 5 stars5/5Stop Asking Questions: How to Lead High-Impact Interviews and Learn Anything from Anyone Rating: 5 out of 5 stars5/5Surveillance and Surveillance Detection: A CIA Insider's Guide Rating: 0 out of 5 stars0 ratings200+ Ways to Protect Your Privacy: Simple Ways to Prevent Hacks and Protect Your Privacy--On and Offline Rating: 0 out of 5 stars0 ratingsThe Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5How To Make Money Blogging: How I Replaced My Day-Job With My Blog and How You Can Start A Blog Today Rating: 4 out of 5 stars4/5Six Figure Blogging In 3 Months Rating: 4 out of 5 stars4/5Hacking : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Ethical Hacking Rating: 5 out of 5 stars5/5How To Start A Podcast Rating: 4 out of 5 stars4/5Wordpress for Beginners: The Easy Step-by-Step Guide to Creating a Website with WordPress Rating: 5 out of 5 stars5/5Mike Meyers' CompTIA Security+ Certification Guide, Third Edition (Exam SY0-601) Rating: 5 out of 5 stars5/5How To Start A Profitable Authority Blog In Under One Hour Rating: 5 out of 5 stars5/5Python QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratingsEverybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5
Reviews for Creating Dynamic UI with Android Fragments
0 ratings0 reviews
Book preview
Creating Dynamic UI with Android Fragments - Jim Wilson
Table of Contents
Creating Dynamic UI with Android Fragments
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Fragments and UI Modularization
The need for a new approach to UI creation
The broad platform support of fragments
Fragments simplify common Android tasks
The relationship between fragments and activities
Making the shift to fragments
The old thinking – activity-oriented
Defining the activity appearance
Displaying the activity UI
The new thinking – fragment-oriented
Creating the fragment layout resources
Defining the layout as a reusable list
Minimize assumptions
Encapsulating the display layout
Creating the Fragment class
Wrapping the list in a fragment
Providing the display fragment
Converting the activity to use fragments
Activities and backward compatibility
Summary
2. Fragments and UI Flexibility
Creating UI flexibility
Dynamic fragment layout selection
Adding an alternate layout resource
Managing fragment layout by screen size
Resource screen size groups
Resource screen size qualifiers
Eliminating redundancy
Layout aliasing
Design fragments for flexibility
Avoiding tight coupling
Abstracting fragment relationships
Defining the callback interface
Making the fragment self-contained
Fragment notification
Encapsulating fragment operations
Loosely connecting the pieces
Fragments protect against the unexpected
Evolving layout resource files
Creating the book description activity
Making the MainActivity class adaptive
Summary
3. Fragment Lifecycle and Specialization
Understanding the fragment lifecycle
Understanding fragment setup and display
Avoiding method name confusion
Understanding fragment hide and teardown
Maximizing available resources
Managing a fragment state
Special purpose fragment classes
ListFragment
Associating data with the list
Separating data from display
Creating the ListFragment derived class
Handling ListFragment item selection
Updating the layout resources
DialogFragment
Styles
Layout
DialogFragment display
Event handling
Dialog identity
Accessing Dialog related behavior
Wrapping an existing dialog in a fragment
Summary
4. Working with Fragment Transactions
Intentional screen management
Dynamically managing fragments
Deferred execution of transaction changes
Adding and removing fragments
Supporting the back button
Creating an adaptive application layout
Updating the layout to support dynamic fragments
Adapting to device differences
Dynamically loading a fragment at startup
Transitioning between fragments
Eliminating redundant handling
Creating the fragment on-the-fly
Managing asynchronous creation
Putting it all together
Summary
5. Creating Rich Navigation with Fragments
A brave new world
Making navigation fun with swipe
Implementing swipe navigation
Managing the swipe fragments
Putting the swipe UI into place
Android Studio and swipe navigation
Improving navigation with the ActionBar
Navigating randomly with tabs
Managing tab selection
Connecting the fragments to the tabs
Providing direct access with drop-down list navigation
Managing fragment selection
Providing the navigation choices
Android Studio and drop-down list navigation
Summary
Index
Creating Dynamic UI with Android Fragments
Creating Dynamic UI with Android Fragments
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2013
Production Reference: 1180913
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78328-309-5
www.packtpub.com
Cover Image by Asher Wishkerman (<wishkerman@hotmail.com>)
Credits
Author
Jim Wilson
Reviewers
Robert Dale Johnson III
Alex Lockwood
Acquisition Editor
Edward Gordon
Anthony Albuquerque
Commissioning Editor
Poonam Jain
Technical Editors
Pratik More
Anusri Ramchandran
Project Coordinator
Michelle Quadros
Proofreader
Jonathan Todd
Indexer
Priya Subramani
Graphics
Sheetal Aute
Production Coordinator
Kyle Albuquerque
Cover Work
Kyle Albuquerque
About the Author
Jim Wilson is president of JW Hedgehog, Inc., a consulting firm specializing in solutions for the Android, iOS, and Microsoft platforms. Jim has nearly 30 years of software engineering experience, with the past 13 years heavily focused on creating mobile device and location-based solutions. After nearly a decade as a Microsoft Device Application Development MVP, Jim now focuses on developing Android and iOS device applications.
Jim's passion is teaching and mentoring software developers. He is a regular contributor of Android-related training materials to Pluralsight (http://training.jwhh.com), a leading provider of online developer training. Jim has authored more than 30 articles on device application development, and has developed mobility and smart client curriculums for several organizations. You can find Jim speaking at a variety of industry conferences, including AnDevCon, Microsoft Professional Developers Conference, Tech Ed, VS Live, Mobile and Embedded Developers Conference, and many others.
Jim and his wife, along with several cats, live in Celebration, Florida (just 3 miles from Walt Disney World). Check out Jim's blog (http://blog.jwhh.com) where he talks about a variety of mobile software development issues as well as the fun of life just 3 miles from the House of Mouse
.
You can reach Jim at <androidtraining@jwhh.com>.
Acknowledgments
First and foremost I want to thank my beloved wife, Bonnie. Without her support and patience through the many long nights and six (often seven) day work weeks, this project (and so many others) would never have happened. Our life together has grown into more than I could have ever hoped or dreamed. I love you.
Thank you to my dear friend Rev. Dr. William A. Lewis of Community Presbyterian Church in Celebration. Your friendship and guidance have opened my eyes up to a life of joy and purpose beyond imagination.
To all the folks at Pluralsight, thank you for creating an organization that offers people like me the opportunity to dig deep into technology and share the knowledge gained with others.
About the Reviewers
Robert Dale Johnson III is a Software Engineer who specializes in Android, Joomla, and BD-J (BluRay Disc – Java) development. He graduated in 2008 from California State University Northridge with a BS in Computer Science. He started his career working with BD-J for Deluxe Digital Studios (DDS), Panasonic, and Deluxe Digital Distribution (D3), where he worked on movie titles such as Avatar, Oceans, Spinal Tap, and Conquest of the Planet of the Apes along with many other titles and web-enabled BluRay features. During his time at D3, Robert made the transition from BD-J to Android development where he was a principal developer on the StarzPlay, EncorePlay, and MovieplexPlay apps. He also worked on the NookVideo app developed for non-Nook devices. During his time with D3 Robert moved to Nashville, TN and eventually found Aloompa LLC where he found a home as a Senior Android Developer developing applications for festivals throughout the country such as Coachella, Stagecoach, Governsball, Bannaroo, and many more.
Along with his fulltime professional pursuits, Robert is a seasoned freelancer with many projects in his repertoire (see his personal website www.rdjiii.info) and has started a software consulting company, Contrahere Solutions LLC (see www.contrahere.com). You can reach Robert by going to one of the websites previously mentioned or by e-mail anytime at
I would like to thank my son Xander Johnson for being the best son I could ever wish for. His love and appreciation drives me to become the best that I can, pushing me forward with a smile on my face and joy in my heart. Xander, I love you and thank you for everything you have and will do to make me a better person.
Alex Lockwood is an experienced developer/consultant in the Android community, and an active user on StackOverflow. His blog can be found at http://www.androiddesignpatterns.com.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book