毕业设计英文Word文档格式.docx
- 文档编号:15320050
- 上传时间:2022-10-29
- 格式:DOCX
- 页数:13
- 大小:176.57KB
毕业设计英文Word文档格式.docx
《毕业设计英文Word文档格式.docx》由会员分享,可在线阅读,更多相关《毕业设计英文Word文档格式.docx(13页珍藏版)》请在冰豆网上搜索。
Anapplicationusuallyconsistsofmultipleactivitiesthatarelooselyboundtoeachother.Typically,oneactivityinanapplicationisspecifiedasthe"
main"
activity,whichispresentedtotheuserwhenlaunchingtheapplicationforthefirsttime.Eachactivitycanthenstartanotheractivityinordertoperformdifferentactions.Eachtimeanewactivitystarts,thepreviousactivityisstopped,butthesystempreservestheactivityinastack(the"
backstack"
).Whenanewactivitystarts,itispushedontothebackstackandtakesuserfocus.Thebackstackabidestothebasic"
lastin,firstout"
stackmechanism,so,whentheuserisdonewiththecurrentactivityandpressestheBack
button,itispoppedfromthestack(anddestroyed)andthepreviousactivityresumes.(ThebackstackisdiscussedmoreintheTasksandBackStack
document.)
Whenanactivityisstoppedbecauseanewactivitystarts,itisnotifiedofthischangeinstatethroughtheactivity'
slifecyclecallbackmethods.Thereareseveralcallbackmethodsthatanactivitymightreceive,duetoachangeinitsstate—whetherthesystemiscreatingit,stoppingit,resumingit,ordestroyingit—andeachcallbackprovidesyoutheopportunitytoperformspecificworkthat'
sappropriatetothatstatechange.Forinstance,whenstopped,youractivityshouldreleaseanylargeobjects,suchasnetworkordatabaseconnections.Whentheactivityresumes,youcanreacquirethenecessaryresourcesandresumeactionsthatwereinterrupted.Thesestatetransitionsareallpartoftheactivitylifecycle.
Therestofthisdocumentdiscussesthebasicsofhowtobuildanduseanactivity,includingacompletediscussionofhowtheactivitylifecycleworks,soyoucanproperlymanagethetransitionbetweenvariousactivitystates.
CreatinganActivity
Tocreateanactivity,youmustcreateasubclassof
(oranexistingsubclassofit).Inyoursubclass,youneedtoimplementcallbackmethodsthatthesystemcallswhentheactivitytransitionsbetweenvariousstatesofitslifecycle,suchaswhentheactivityisbeingcreated,stopped,resumed,ordestroyed.Thetwomostimportantcallbackmethodsare:
onCreate()
Youmustimplementthismethod.Thesystemcallsthiswhencreatingyouractivity.Withinyourimplementation,youshouldinitializetheessentialcomponentsofyouractivity.Mostimportantly,thisiswhereyoumustcall
setContentView()
todefinethelayoutfortheactivity'
suserinterface.
onPause()
Thesystemcallsthismethodasthefirstindicationthattheuserisleavingyouractivity(thoughitdoesnotalwaysmeantheactivityisbeingdestroyed).Thisisusuallywhereyoushouldcommitanychangesthatshouldbepersistedbeyondthecurrentusersession(becausetheusermightnotcomeback).
Thereareseveralotherlifecyclecallbackmethodsthatyoushoulduseinordertoprovideafluiduserexperiencebetweenactivitiesandhandleunexpectedinteruptionsthatcauseyouractivitytobestoppedandevendestroyed.Allofthelifecyclecallbackmethodsarediscussedlater,inthesectionabout
ManagingtheActivityLifecycle.
Implementingauserinterface
Theuserinterfaceforanactivityisprovidedbyahierarchyofviews—objectsderivedfromthe
View
class.Eachviewcontrolsaparticularrectangularspacewithintheactivity'
swindowandcanrespondtouserinteraction.Forexample,aviewmightbeabuttonthatinitiatesanactionwhentheusertouchesit.
Androidprovidesanumberofready-madeviewsthatyoucanusetodesignandorganizeyourlayout."
Widgets"
areviewsthatprovideavisual(andinteractive)elementsforthescreen,suchasabutton,textfield,checkbox,orjustanimage."
Layouts"
areviewsderivedfrom
ViewGroup
thatprovideauniquelayoutmodelforitschildviews,suchasalinearlayout,agridlayout,orrelativelayout.Youcanalsosubclassthe
and
classes(orexistingsubclasses)tocreateyourownwidgetsandlayoutsandapplythemtoyouractivitylayout.
ThemostcommonwaytodefinealayoutusingviewsiswithanXMLlayoutfilesavedinyourapplicationresources.Thisway,youcanmaintainthedesignofyouruserinterfaceseparatelyfromthesourcecodethatdefinestheactivity'
sbehavior.YoucansetthelayoutastheUIforyouractivitywith
setContentView(),passingtheresourceIDforthelayout.However,youcanalsocreatenew
Viewsinyouractivitycodeandbuildaviewhierarchybyinsertingnew
Viewsintoa
ViewGroup,thenusethatlayoutbypassingtheroot
V
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 毕业设计 英文