MurphyAndroid2BeginningCompanioneBookAvailableBeginningAndroid2Trim:7.5x9.25spine=0.78125416pagecountBeginthejourneytowardyourownsuccessfulAndroid2applicationsMarkL.MurphyCOMPANIONeBOOKSEELASTPAGEFORDETAILSON$10eBOOKVERSIONUS$44.99ShelveinMobileComputingUserlevel:Beginner®ISBN978-1-4302-2629-1978143022629154499thisprintforcontentonly—size&colornotaccurateCYANMAGENTAYELLOWBLACKPANTONE123CSPOTMATTEFirst,welcometotheworldofAndroid!Asyouhaveprobablynoticed,Androidisrapidlygrowing;withthereleaseofAndroid2,manydevicesfromvariousmanufacturersaredottingthelandscape.Withmillionsofde-vicesinthewild,andmillionsmoreontheway,thosewhogetintothelatestversionofAndroidearlywillreapthebenefitsastheecosystemcon-tinuestogrow.Second,welcometotheneweditionofthisbook,whichnowcoversAndroid2!ItspurposeistostartyouonyourwaytobuildingcompellingAndroid2ap-plications,andtohelpyoumasterthelearningcurve.Android2isarichframe-work,whichmeansthatthereisalotofcoolstuffforyoutopickupalongyourjourneyinordertocreatetheslickest,mostusefulappsyoucanimagine.Android2isanimportantreleaseoftheframework,soit’simportanttogetofftothebestpossiblestartwhenlearningtheinsandoutsofAndroid2development.ThisbookguidesyouonyourjourneytolearningAndroid2,pointingoutwhatispossibleandshowingyouhowtoturnthoseconceptsintoreality.Fromthere,buildingpracticalandpopularappsisamatteroftimeandcreativity.Android2ISBN978-1-4302-2629-1978143022629154499iBeginningAndroid2■■■MarkL.MurphyiiBeginningAndroid2Copyright©2010byMarkL.MurphyAllrightsreserved.Nopartofthisworkmaybereproducedortransmittedinanyformorbyanymeans,electronicormechanical,includingphotocopying,recording,orbyanyinformationstorageorretrievalsystem,withoutthepriorwrittenpermissionofthecopyrightownerandthepublisher.ISBN-13(pbk):978-1-4302-2629-1ISBN-13(electronic):978-1-4302-2630-7PrintedandboundintheUnitedStatesofAmerica987654321Trademarkednamesmayappearinthisbook.Ratherthanuseatrademarksymbolwitheveryoccurrenceofatrademarkedname,weusethenamesonlyinaneditorialfashionandtothebenefitofthetrademarkowner,withnointentionofinfringementofthetrademark.Java™andallJava-basedmarksaretrademarksorregisteredtrademarksofSunMicrosystems,Inc.,intheUSandothercountries.Apress,Inc.,isnotaffiliatedwithSunMicrosystems,Inc.,andthisbookwaswrittenwithoutendorsementfromSunMicrosystems,Inc.PresidentandPublisher:PaulManningLeadEditor:SteveAnglinDevelopmentEditor:MatthewMoodieEditorialBoard:ClayAndres,SteveAnglin,MarkBeckner,EwanBuckingham,GaryCornell,JonathanGennick,JonathanHassell,MichelleLowman,MatthewMoodie,DuncanParkes,JeffreyPepper,FrankPohlmann,DouglasPundick,BenRenow-Clarke,DominicShakeshaft,MattWade,TomWelshCoordinatingEditor:FranParnellCopyEditor:MarilynS.SmithCompositor:MacPS,LLCIndexer:JohnCollinArtist:AprilMilneCoverDesigner:AnnaIshchenkoDistributedtothebooktradeworldwidebySpringer-VerlagNewYork,Inc.,233SpringStreet,6thFloor,NewYork,NY10013.Phone1-800-SPRINGER,fax201-348-4505,e-mailorders-ny@springer-sbm.com,orvisit@apress.com,orvisit–eBookLicensingwebpageat“asis”basis,withoutwarranty.Althougheveryprecautionhasbeentakeninthepreparationofthiswork,neithertheauthor(s)norApressshallhaveanyliabilitytoanypersonorentitywithrespecttoanylossordamagecausedorallegedtobecauseddirectlyorindirectlybytheinformationcontainedinthiswork.iiiivContentsataGlance■ContentsataGlance.................................................................................................................................iv■Contents.....................................................................................................................................................v■AbouttheAuthor.....................................................................................................................................xiii■Acknowledgments...................................................................................................................................xiv■Preface......................................................................................................................................................xv■Chapter1:TheBigPicture.........................................................................................................................1■Chapter2:ProjectsandTargets................................................................................................................5■Chapter3:CreatingaSkeletonApplication.............................................................................................17■Chapter4:UsingXML-BasedLayouts..............................................................................................