Android Programming Tutorials, 3rd Editi - Murphy_ Mark L.pdf

(15186 KB) Pobierz
Android Programming Tutorials Version 3.2
686457386.006.png 686457386.007.png 686457386.008.png 686457386.009.png 686457386.001.png 686457386.002.png
Android Programming Tutorials
by M ark L. M urphy
686457386.003.png
Android Programming T utorials
by Mark L. M urphy
Copyright © 2009-2011 CommonsW are, LLC. All Rights Reserved.
Printed in the United States of America.
CommonsW are books may be purchased in printed (bulk) or digital form for educational or
business use. F or more information, contact direct@commonsware.com .
Printing History:
Mar 2011:V ersion 3.2 ISBN: 978-0-9816780-4-7
The CommonsW are name and logo, “Busy Coder's Guide”,and related trade dress are
trademarks of CommonsW are, 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.
able of Contents
Welcome to the Warescription!. ........................................................xiii
Preface..................................................................................................xv
Welcome to the Book! . ...............................................................................xv
Prerequisites . ...............................................................................................xv
Using the Tutorials . ...................................................................................xvi
Warescription . .........................................................................................xviii
What's New . .............................................................................................xviii
About the "Further Reading" Sections . ....................................................xix
Errata and Book Bug Bounty . ...................................................................xix
Source Code License . ..................................................................................xx
Lifecycle of a CommonsWare Book . ........................................................xxi
Roster of Tutorials . ...................................................................................xxii
Your First Android Project. ....................................................................1
Step #1: Create the New Project . ..................................................................1
Step #1: Eclipse . ......................................................................................2
Step #2: Command Line . .......................................................................5
Device . ...........................................................................................................6
iii
686457386.004.png
Step #1: Eclipse . ......................................................................................6
Step #2: Command Line . .......................................................................7
A Simple Form. ......................................................................................11
Step-By-Step Instructions . ..........................................................................11
Step #1: Generate the Application Skeleton . .......................................11
Step #2: Modify the Layout . .................................................................12
Step #3: Support All Screen Sizes ........................................................14
Step #4: Compile and Install the Application . ....................................15
Step #5: Run the Application in the Emulator . ..................................15
Step #6: Create a Model Class . ............................................................16
Step #7: Save the Form to the Model . .................................................16
Extra Credit . .................................................................................................18
Further Reading . .........................................................................................18
A Fancier Form......................................................................................19
Step-By-Step Instructions . ..........................................................................19
Step #1: Switch to a TableLayout . ........................................................19
Step #2: Add a RadioGroup . .................................................................21
Step #3: Update the Model . .................................................................23
Step #4: Save the Type to the Model . .................................................24
Extra Credit . ................................................................................................26
Further Reading . .........................................................................................27
Adding a List.........................................................................................29
Step-By-Step Instructions . .........................................................................29
Step #1: Hold a List of Restaurants . ....................................................29
Step #2: Save Adds to List . ...................................................................30
Step #3: Implement toString() . ............................................................31
Step #4: Add a ListView Widget . .........................................................31
iv
686457386.005.png
Zgłoś jeśli naruszono regulamin