26,39 €
Create engaging apps with fragments to provide a rich user interface that dynamically adapts to the individual characteristics of your customers' tablets and smartphones
This book is for developers with a basic understanding of Android programming who would like to improve the appearance and usability of their applications by creating a more interactive user experience and dynamically adaptive UIs; providing better support for tablets and smartphones in a single app; and reducing the complexity of managing app UIs.
Today's users expect mobile apps to be dynamic and highly interactive, with rich navigation features. These same apps must look fantastic whether running on a medium-resolution smartphone or high-resolution tablet. Fragments provide the toolset we need to meet these user expectations by enabling us to build our applications out of adaptable components that take advantage of the rich capabilities of each individual device and automatically adapt to their differences.
This book looks at the impact fragments have on Android UI design and their role in both simplifying many common UI challenges and in providing best practices for incorporating rich UI behaviors. We look closely at the roll of fragment transactions and how to work with the Android back stack. Leveraging this understanding, we explore several specialized fragment-related classes such as ListFragment and DialogFragment. We then go on to discuss how to implement rich navigation features such as swipe-based screen browsing, and the role of fragments when developing applications that take advantage of the latest aspects of Material Design.
You will learn everything you need to provide dynamic, multi-screen UIs within a single activity, and the rich UI features demanded by today's mobile users.
A fast-paced learning guide that gives a hands-on, code-intensive approach with a focus on real-world applications.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 177
Veröffentlichungsjahr: 2016
Copyright © 2016 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
Second edition: March 2016
Production reference: 1170316
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-959-2
www.packtpub.com
Author
Jim Wilson
Reviewers
Nayanesh Ramchandra Gupte
Robert Dale Johnson III
Commissioning Editor
Edward Gordon
Acquisition Editor
Kirk D'costa
Content Development Editor
Mehvash Fatima
Technical Editor
Dhiraj Chandanshive
Copy Editor
Shruti Iyer
Project Coordinator
Kinjal Bari
Proofreader
Safis Editing
Indexer
Rekha Nair
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
Jim Wilson is the President of JW Hedgehog, Inc., a consulting firm specializing in solutions for the Android, iOS, and Microsoft platforms. He has over 30 years of software engineering experience, with the past 15 years heavily focused on creating mobile device and location-based solutions. Jim cofounded multiple software-related startups and has served in a consulting role at several more. After nearly a decade as a Microsoft Device Application Development MVP, he now focuses on developing Android and iOS device applications.
Jim's passion is mentoring software developers. He is a regular contributor of Android, iOS, and Xamarin training material at 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 served as a contributing expert on mobile software development issues for a variety of media outlets.
Jim and his wife, along with several cats, split their time between Celebration, Florida (just three miles from Walt Disney World) and Weirs Beach, New Hampshire. You can take a look at his blog (http://blog.jwhh.com) where he talks about a variety of mobile software development issues as well as the adventures of a life split between the busy region of the "House of Mouse" and the quietness of NH's lakes and mountains.
You can reach Jim at <[email protected]>.
Nayanesh Ramchandra Gupte is an enthusiastic Android professional based in Bengaluru, the Silicon Valley of India. He is a full stack Android engineer and has explored Android for more than 5 years. Till date, Nayanesh has worked with different organizations and developed more than 40 Android applications. Some of these apps are featured with Top Developers Badge on Google Play. Programming, especially in Java and Android, is not just a part of his career but his passion as well.
Besides being a software engineer, Nayanesh works as an Android consultant and is associated with the Google Developers Group based in Bengaluru. Writing personal blogs and articles on Java and Android remain a few of his interests. He works as a professional Android trainer and pursues teaching and illustration as his hobbies.
Associated with one of the e-commerce giants in India, Nayanesh is part of the core engineering team. He also works closely with the Product and UX teams to build a next-generation platform for e-commerce.
You can get in touch with Nayanesh through various channels at https://about.me/NayaneshGupte and https://www.linkedin.com/in/nayaneshgupte
To begin with, I credit my parents who have always nurtured my dreams and constantly supported me in making them come true. I thank my wife, Aakanksha, and my in-laws, who have trusted my dynamic decisions while I hopped cities and organizations with the aim of improving my career. I sincerely thank Mr. Sudarshan Shetty, my guide, because of whom I got engrossed in Java and Android. His teachings have brought me a long way. I am sure there is much more to explore. I owe a lot to my best buddies, Saurabh Lele and Rahul Gangal, since it was all because of them that I decided to get into this field of programming. The journey would have been incomplete without my colleagues and mentors Rishi and Vishal from whom I learnt what a passion for programming really is! Last but not least, I would like to thank Packt Publishing for offering me this opportunity.
Robert Dale Johnson III is an experienced developer/consultant who has worked primarily with Android over the past 5 years. He has also worked with many other technologies and frameworks, from BD-J (BluRay Disc-Java) and Java to Joomla, and many of the languages and technologies related to them.
Along with his full-time professional pursuits, he is a seasoned freelancer who has worked on dozens of projects and applications. To find out more about Robert and his portfolio, take a look at his personal website, www.rdjiii.info, or feel free to reach out to him through his consultancy company, Contrahere Solutions LLC, at www.contrahere.com.
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 done, and will do, to make me a better person personally, morally, and professionally.
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 <[email protected]> for more details.
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.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Long gone are the days of mobile apps with a static UI squished on a tiny screen. Today's users expect mobile apps to be dynamic and highly interactive. They expect an app to look fantastic when they look at it on their medium resolution smartphone and just as fantastic when they switch over to using it on their high-resolution tablet. Apps need to provide rich navigation features, be adaptive, and be responsive.
Trying to meet these demands using Android's traditional activity-centric UI design model is difficult at best. As developers, we need more control than that afforded by activities. We need a new approach, and fragments give us this new approach.
In this book, you'll learn how to use fragments to meet the challenges of creating dynamic UIs in the modern world of mobile app development.
Chapter 1, Fragments and UI Modularization, introduces fragments, UI modularization, and the role that fragments play in developing a modularized UI. This chapter demonstrates creating simple fragments and using fragments statically within activities.
Chapter 2, Fragments and UI Flexibility, builds on the concepts introduced in the previous chapter to provide solutions to specific differences in device layouts. This chapter explains how to use adaptive activity layout definitions to provide support for a wide variety of device form factors with a small set of fragments that are automatically rearranged based on the current device's UI requirements.
Chapter 3, Fragment Life Cycle and Specialization, discusses the relationship of the life cycle of fragments with that of activities and demonstrates the appropriate programming actions at the various points in the life cycle. Leveraging this knowledge, the special purpose fragment classes, ListFragment and DialogFragment, are introduced to demonstrate their behavior and provide a deeper understanding of how their behavior in the activity life cycle differs from that of standard fragments.
Chapter 4, Working with Fragment Transactions, explains how to create multiple app screens within a single activity by dynamically adding and removing fragments using fragment transactions. Topics covered include thread handling, implementing back button behavior, and dynamically adapting multifragment UIs to differences in device characteristics.
Chapter 5, Creating Rich Navigation, brings everything together by building on the previous chapters to show how to use fragments to enhance the user's experience through rich navigation features. This chapter demonstrates how to implement a number of navigation features, including screen browsing with swipe-based paging, direct screen access with drop-down list navigation, and random screen viewing with tabs.
Chapter 6, Fragments and Material Design, introduces the next generation of application development using material design. This chapter demonstrates how to implement fragments that incorporate a rich visual appearance and animated transitions using the latest features of Android's material design capabilities.
To follow the examples in this book, you should have a basic knowledge of Android programming and a working Android development environment.
This book focuses primarily on Android Studio and the Android development environment; however, other tools, such as Eclipse with the ADT plugin, JetBrains' IntelliJ IDEA IDE, or a similar Android-enabled development tool, can also be used.
This book is for anyone with a basic understanding of Android programming who would like to improve the appearance and usability of their applications.
Whether you're looking to create a more interactive user experience, create more dynamically adaptive UIs, provide better support for tablets and smartphones in a single app, reduce the complexity of managing your app UIs, or just trying to expand your UI design philosophy, this book is for you.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "To create a fragment for the book list, we will define a new layout resource file called fragment_book_list.xml."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "In Android Studio, we associate a resource file with this qualifier by selecting Screen Height in the New Resource File dialog."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/CreatingDynamicUIwithAndroidFragmentsSecondEdition_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
