Android Programming, 3RD Edition

LI
lienhejb
0 lượt tải
2464
0

Nội dung tài liệu

Trang 2

Android Programming: The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart and Kristin Marsicano Copyright © 2017 Big Nerd Ranch, LLC.

Trang 3

All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, contact Big Nerd Ranch, LLC. 200 Arizona Ave NE Atlanta, GA 30307 (770) 817-6373 http://www.bignerdranch.com/ book-comments@bignerdranch.com

Trang 4

The 10-gallon hat with propeller logo is a trademark of Big Nerd Ranch, Inc. Exclusive worldwide distribution of the English edition of this book by Pearson Technology Group 800 East 96th Street Indianapolis, IN 46240 USA http://www.informit.com The authors and publisher have taken care in writing and printing this book but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or

Trang 5

programs contained herein. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. ISBN-10 0134706072 ISBN-13 978-0134706078 Third edition, first printing, February 2017 Release E.3.1.1

Trang 6

Dedication To the record player on my desk. Thanks for keeping me company through all this. I promise I’ll get you a new needle soon. — B.P. To my dad, David, for teaching me the value of hard work. To my mom, Lisa, for pushing me to always do the right thing. — C.S.

Trang 7

To my dad, Dave Vadas, for inspiring and encouraging me to pursue a career in computing. And to my mom, Joan Vadas, for cheering me on through all the ups and downs (and for reminding me that watching an episode of The Golden Girls always makes things better). — K.M.

Trang 8

Acknowledgmen With this being our third edition, we find ourselves used to saying this. It always needs to be said, though: Books are not created by authors alone. They are shepherded into existence by a community of collaborators, risk-takers, and other supporters, without whom the burden of comprehending and writing all this material would be crippling. Brian Hardy, who, along with Bill, had the gusto to bring the very first edition of this book into the world. From nothing,

Trang 9

Brian and Bill made something great. Our co-instructors and members of our Android development team: Andrew Lunsford, Bolot Kerimbaev, Brian Gardner, David Greenhalgh, Josh Skeen, Matt Compton, Paul Turner, and Rashad Cureton. (Soon, Rashad. Soon.) They taught everything in this book before it was polished enough to be presentable and gave us many invaluable suggestions and corrections. Most people live their entire lives without ever working with such a talented

Trang 10

and entertaining crew. They make work at Big Nerd Ranch an everyday joy. Special thanks to Andrew, who went through the entire book and updated all the Android Studio screenshots. We appreciate his thoroughness, attention to detail, and acerbic wit. Zack Simon, our fantastically talented and soft-spoken Big Nerd Ranch designer. Unbeknownst to us, Zack went behind our backs and updated the nifty cheat sheet you can find attached to this book. If

Trang 11

you enjoy that sheet, you should find Zack and tell him so yourself. But we will also thank Zack right here: Thanks, Zack! Kar Loong Wong, for his work redesigning the crime list screen. The more help we get from Kar, the better the apps in this book look. Thanks, Kar. Mark Dalrymple, who reviewed our constraint layout coverage for accuracy and wonderfulness. If you happen to run into Mark, ask him to review your constraint layout coverage. He is so good at

Trang 12

doing that! But if you have none, ask him to make balloon animals for you instead. Thanks to Aaron Hillegass. As a practical matter, it is not possible to do this work without Big Nerd Ranch, the company Aaron founded. Thank you. Our editor, Elizabeth Holaday. The famous beat author William S. Burroughs sometimes wrote by cutting up his work into little pieces, throwing them in the air, and publishing the rearrangement. Without a strong editor like

Trang 13

Liz, our confusion and simpleminded excitement may have caused us to resort to such techniques. We are thankful that she was there to impose focus, precision, and clarity on our drafts. Ellie Volckhausen, who designed our cover. Anna Bentley, our copyeditor, and Simone Payment, our proofreader. Thank you both for sanding away the remaining rough edges of this book. Chris Loper at IntelligentEnglish.com, who designed and produced the

Trang 14

print and ebook versions of the book. His DocBook toolchain made life much easier, too. Finally, thanks to our students. There is a feedback loop between us and our students: We teach them out of these materials, and they respond to it. Without that loop, this book could never have existed, nor could it be maintained. If Big Nerd Ranch books are special (and we hope they are), it is that feedback loop that makes them so. Thank you.

Trang 15

Table of Contents Learning Android Prerequisites What’s New in the Third Edition? How to Use This Book How This Book Is Organized Challenges Are you more curious? Code Style Typographical Conventions Using an eBook Android Versions

Trang 16

The Necessary Tools Downloading and Installing Android Studio Downloading Earlier SDK Versions A Hardware Device 1. Your First Android Application App Basics Creating an Android Project Navigating in Android Studio Laying Out the UI The view hierarchy Widget attributes Creating string resources Previewing the layout From Layout XML to View Objects

Trang 17

Resources and resource IDs Wiring Up Widgets Getting references to widgets Setting listeners Making Toasts Using code completion Running on the Emulator For the More Curious: Android Build Process Android build tools Challenges Challenge: Customizing the Toast 2. Android and Model-View- Controller Creating a New Class

Trang 18

Generating getters and setters Model-View-Controller and Android Benefits of MVC Updating the View Layer Updating the Controller Layer Running on a Device Connecting your device Configuring your device for development Adding an Icon Adding resources to a project Referencing resources in XML Challenge: Add a Listener to the

Trang 19

TextView Challenge: Add a Previous Button Challenge: From Button to ImageButton 3. The Activity Lifecycle Logging the Activity Lifecycle Making log messages Using Logcat Exploring the activity lifecycle by example Rotation and the Activity Lifecycle Device configurations and alternative resources Saving Data Across Rotation Overriding

Trang 20

onSaveInstanceState(Bundle) The Activity Lifecycle, Revisited For the More Curious: Current State of Activity Cleanup For the More Curious: Log Levels and Methods Challenge: Preventing Repeat Answers Challenge: Graded Quiz 4. Debugging Android Apps Exceptions and Stack Traces Diagnosing misbehaviors Logging stack traces Setting breakpoints Using exception breakpoints Android-Specific Debugging Using Android Lint

Hiển thị 20 trang đầu. Tải tài liệu để xem đầy đủ.

Bình luận (0)

Đăng nhập để tham gia bình luận

Chưa có bình luận nào. Hãy là người đầu tiên!