




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
基于Android開發(fā)的外文文獻(完整資料)(可以直接使用,可編輯優(yōu)秀版資料,歡迎下載)
Android基于Android開發(fā)的外文文獻(完整資料)(可以直接使用,可編輯優(yōu)秀版資料,歡迎下載)Android,asasystem,isaJava-basedoperatingsystemthatrunsontheLinux2。6kernel。Thesystemisverylightweightandfullfeat(yī)ured。Androidapplicat(yī)ionsaredevelopedusingJavaandcanbeportedrathereasilytothenewplatform.IfyouhavenotyetdownloadedJavaorareunsureaboutwhichversionyouneed,Idetailtheinstallat(yī)ionofthedevelopmentenvironmentinChapter2.OtherfeaturesofAndroidincludeanaccelerated3-Dgraphicsengine(basedonhardwaresupport),dat(yī)abasesupportpoweredbySQLite,andanintegratedwebbrowser。IfyouarefamiliarwithJavaprogrammingorareanOOPdeveloperofanysort,youarelikelyusedtoprogrammaticuserinterface(UI)development—thatis,UIplacementwhichishandleddirectlywithintheprogramcode.Android,whilerecognizingandallowinggrammaticUIdevelopment,alsosupportsthenewer,XML-basedUIlayout.XMLUIlayoutisafairlynewconcepttotheaveragedesktopdeveloper。IwillcoverboththeXMLUIlaygrammat(yī)icUIdevelopmentinthesupportingchaptersofthisbook。OneofthemoreexcitingandcompellingfeaturesofAndroidisthat,becauseofitsarchitecture,third-partyapplicat(yī)ions-includingthosethatare“homegrown"—areexecutedwiththesamesystempriorityasthosethatarebundledwiththecoresystem.Thisisamajordeparturefrommostsystems,whichgiveembeddedsystemappsagreaterexecutionprioritythanthethreadpriorityavailabletoappscreatedbythird-partydevelopers。Also,eachapplicationisexecutedwithinitsownthreadusingaverylightweightvirtualmachine.AsidefromtheverygenerousSDKandthewell—formedlibrariesthat(yī)areavailabletoustodevelopwith,themostexcitingfeatureforAndroiddevelopersisthatwenowhaveaccesstoanythingtheoperatingsystemhasaccessto。Inotherwords,ifyouwanttocreateanapplicat(yī)ionthatdialsthephone,youhaveaccesstothephone'sdialer;ifyouwanttocreat(yī)eanapplicationthat(yī)utilizesthephone’ernalGPS(ifequipped),youhaveaccesstoit。Thepotentialfordeveloperstocreatedynamicandintriguingapplicationsisnowwideopen。Ontopofallthefeat(yī)uresthatareavailablefromtheAndroidsideoftheequation,Googlehasthrowninsomeverytantalizingfeaturesofitsown.DevelopersofAndroidapplicat(yī)ionswillbeabletotietheirapplicat(yī)ionsintoexistingGoogleofferingssuchasGoogleMapsandtheomnipresentGoogleSearch.SupposeyouwanttowriteanapplicationthatpullsupaGooglemapofwhereanincomingcallisemanatingfrom,oryouwanttobeabletostorecommonsearchresultswithyourcontacts;thedoorsofpossibilityhavebeenflungwideopenwithAndroid。Chapter2beginsyourjourneytoAndroiddevelopment。Youwilllearnthehow'sandwhy’sofusingspecificdevelopmentenvironmentsorintegrateddevelopmentenvironments(IDE),andyouwilldownloadandinstalltheJavaIDEEclipse。Applicat(yī)ionComponentsAcentralfeatureofAndroidisthatoneapplicat(yī)ioncanmakeuseofelementsofotherapplicat(yī)ions(providedthoseapplicat(yī)ionspermitit)。Forexample,ifyourapplicationneedstodisplayascrollinglistofimagesandanotherapplicationhasdevelopedasuitablescrollerandmadeitavailabletoothers,youcancalluponthatscrollertodothework,rat(yī)herthandevelopyourown.Yourapplicationdoesn’tincorporatethecodeoftheotherapplicationorlinktoit.Rather,itsimplystartsupthatpieceoftheotherapplicat(yī)ionwhentheneedarises.Forthistowork,thesystemmustbeabletostartanapplicationprocesswhenanypartofitisneeded,andinstantiatetheJavaobjectsforthatpart。Therefore,unlikeapplicationsonmostothersystems,Androidapplicat(yī)ionsdon’thaveasingleentrypointforeverythingintheapplication(nomain()function,forexample).Rather,theyhaveessentialcomponentsthatthesystemcaninstantiateandrunasneeded.Therearefourtypesofcomponents:ActivitiesAnactivitypresentsavisualuserinterfaceforonefocusedendeavortheusercanundertake.Forexample,anactivitymightpresentalistofmenuitemsuserscanchoosefromoritmightdisplayphotographsalongwiththeircaptions.Atextmessagingapplicationmighthaveoneactivitythatshowsalistofcontactstosendmessagesto,asecondactivitytowritethemessagetothechosencontact,andotheractivitiestoreviewoldmessagesorchangesettings.Thoughtheyworktogethertoformacohesiverface,eachactivityisindependentoftheothers.EachoneisimplementedasasubclassoftheActivitybaseclass。Anapplicationmightconsistofjustoneactivityor,likethetextmessagingapplicationjustmentioned,itmaycontainseveral。Whattheactivitiesare,andhowmanytherearedepends,ofcourse,ontheapplicat(yī)ionanditsdesign.Typically,oneoftheactivitiesismarkedasthefirstonethatshouldbepresentedtotheuserwhentheapplicationislaunched。Movingfromoneactivitytoanotherisaccomplishedbyhavingthecurrentactivitystartthenextone。Eachactivityisgivenadefaultwindowtodrawin。Typically,thewindowfillsthescreen,butitmightbesmallerthanthescreenandfloatontopofotherwindows。Anactivitycanalsomakeuseofadditionalwindows-forexample,apop-updialogthatcallsforauserresponseinthemidstoftheactivity,orawindowthatpresentsuserswithvitalinformationwhentheyselectaparticularitemon—screen。Thevisualcontentofthewindowisprovidedbyahierarchyofviews—objectsderivedfromthebaseViewclass.Eachviewcontrolsaparticularrectangularspacewithinthewindow.Parentviewscontainandorganizethelayoutoftheirchildren.Leafviews(thoseat(yī)thebottomofthehierarchy)drawintherectanglestheycontrolandrespondtouseractionsdirectedatthatspace.Thus,viewsarewheretheactivity'sinteractionwiththeusertakesplace。Forexample,aviewmightdisplayasmallimageandinitiat(yī)eanactionwhentheusertapsthatimage.Androidhasanumberofready—madeviewsthatyoucanuse-includingbuttons,textfields,scrollbars,menuitems,checkboxes,andmore。Aviewhierarchyisplacedwithinanactivity'swindowbytheActivity。setContentView()method。ThecontentviewistheViewobjectattherootofthehierarchy.(Seetheseparat(yī)eUserInterfacedocumentformoreinformationonviewsandthehierarchy.)ServicesAservicedoesn'thaveavisualuserinterface,butratherrunsinthebackgroundforanindefiniteperiodoftime。Forexample,aservicemightplaybackgroundmusicastheuserat(yī)tendstoothermatters,oritmightfetchdataoverthenetworkorcalculatesomethingandprovidetheresulttoactivitiesthatneedit.EachserviceextendstheServicebaseclass。Aprimeexampleisamediaplayerplayingsongsfromaplaylist。Theplayerapplicat(yī)ionwobablyhaveoneormoreactivitiesthatallowtheusertochoosesongsandstartplayingthem.However,themusicplaybackitselfwouldnotbehandledbyanactivitybecauseuserswillexpectthemusictokeepplayingevenaftertheyleavetheplayerandbeginsomethingdifferent.Tokeepthemusicgoing,themediaplayeractivitycouldstartaservicetoruninthebackground。Thesystemwouldthenkeepthemusicplaybackservicerunningevenaftertheactivitythatstarteditleavesthescreen.It'spossibletoconnectto(bindto)anongoingservice(andstarttheserviceifit'snotalreadyrunning)。Whileconnected,youmunicatewiththeservicethroughaninterfacethattheserviceexposes。Forthemusicservice,thisinterfacemightallowuserstopause,rewind,stop,andrestarttheplayback.Likeactivitiesandtheothercomponents,servicesruninthemainthreadoftheapplicationprocess。Sothat(yī)theywon'tblockothercomponentsortheuserinterface,theyoftenspawnanotherthreadfortime-consumingtasks(likemusicplayback).SeeProcessesandThreads,later.BroadcastreceiversAbroadcastreceiverisacomponentthatdoesnothingbutreceiveandreacttobroadcastannouncements。Manybroadcastsoriginateinsystemcode—forexample,announcementsthatthetimezonehaschanged,thatthebatteryislow,thatapicturehasbeentaken,orthat(yī)theuserchangedalanguagepreference.Applicationscanalsoinitiatebroadcasts—forexample,toletotherapplicationsknowthatsomedatahasbeendownloadedtothedeviceandisavailableforthemtouse.Anapplicationcanhaveanynumberofbroadcastreceiverstorespondtoanyannouncementsitconsidersimportant。AllreceiversextendtheBroadcastReceiverbaseclass。Broadcastreceiversdonotdisplayauserinterface.However,theymaystartanactivityinresponsetotheinformationtheyreceive,ortheymayusetheNotificationManagertoalerttheuser。Notificationscangettheuser'sattentioninvariousways—flashingthebacklight,vibratingthedevice,playingasound,andsoon。Theytypicallyplaceapersistenticoninthestatusbar,whichuserscanopentogetthemessage.ContentprovidersAcontentprovidermakesaspecificsetoftheapplication’sdataavailabletootherapplications.Thedatacanbestoredinthefilesystem,inanSQLitedatabase,orinanyothermannerthatmakessense.ThecontentproviderextendstheContentProviderbaseclasstoimplementastandardsetofmethodsthatenableotherapplicationstoretrieveandstoredataofthetypeitcontrols。However,applicationsdonotcallthesemethodsdirectly。RathertheyuseaContentResolverobjectandcallitsmethodsinstead.AContentResolvercantalktoanycontentprovider;erateswiththeprovidertomanageanyinterprocesscommunicationthat'sinvolved。Seetheseparat(yī)eContentProvidersdocumentformoreinformationonusingconteviders。Wheneverthere'sarequestthat(yī)shouldbehandledbyaparticulaponent,Androidmakessurethattheapplicationprocessofthecomponentisrunning,startingitifnecessary,andthat(yī)anappropriateinstanceofthecomponentisavailable,creatingtheinstanceifnecessary.KeySkills&Concepts●CreatingnewAndroidprojects●WorkingwithViews●UsingaTextView●Modifyingthemain.xmlfileCreat(yī)ingYourFirstAndroidProjectinEclipseTostartyourfirstAndroidproject,openEclipse.WhenyouopenEclipseforthefirsttime,itopenstoanemptydevelopmentenvironment(seeFigure5—1),whichiswhereyouwanttobegin.Yourfirsttaskistosetupandnametheworkspaceforyourapplication.ChooseFile|New|AndroidProject,whichwilllaunchtheNewAndroidProjectwizard。CAUTIONDonotselectJavaProjectfromtheNewmenu.WhileAndroidapplicationsarewritteninJava,andyouaredoingallofyourdevelopmentinJavaprojects,thisoptionwillcreateastandardJavaapplication.SelectingAndroidProjectenablesyoutocreateAndroid-specificapplications.IfyoudonotseetheoptionforAndroidProject,thisindicatesthattheAndroidpluginforEclipsewasnotfullyorcorrectlyinstalled。ReviewtheprocedureinChapter3forinstallingtheAndroidpluginforEclipsetocorrectthis.TheNewAndroidProjectwizardcreatestwothingsforyouAshellapplicationthattiesintotheAndroidSDK,usingtheandroid。jarfile,andtiestheprojectintotheAndroidEmulator.ThisallowsyoutocodeusingalloftheAndroidlibrariesandpackages,andalsoletsyoudebugyourapplicationsintheproperenvironment。Yourfirstshellfilesforthenewproject。Theseshellfilescontainsomeofthevitalapplicationblocksuponwhichyouwillbebuildingyourprograms.InmuchthesamewayascreatingaMicrosoft。NETapplicationinVisualStudiogeneratessomeWindows—createdprogramcodeinyourfiles,usingtheAndroidProjectwizardinEclipsegenerat(yī)esyourinitialprogramfilesandsomeAndroid-createdcode.Inaddition,theNewAndroidProjectwizardcontainsafewoptions,shownnext,that(yī)youmustsettoinitiateyourAndroidproject.FortheProjectNamefield,forpurposesofthisexample,usethetitleHelloWorldText.ThisnamesufficientlydistinguishesthisHelloWorld!projectfromtheothersthat(yī)youwillbecreatinginthischapter.IntheContentsarea,keepthedefaultselections:theCreat(yī)eNewProjectinWorkspaceradiobuttonshouldbeselectedandtheUseDefaultLocationcheckboxshouldbechecked。ThiswillallowEclipsetocreateyourprojectinyourdefaultworkspacedirectory.Theadvantageofkeepingthedefaultoptionsisthatyourprojectsarekeptinacentrallocation,whichmakesordering,managing,andfindingtheseprojectsquiteeasy.Forexample,ifyouareworkinginaUnix—basedenvironment,thispat(yī)hpointstoyour$HOMEdirectory.IfyouareworkinginaMicrosoftWindowsenvironment,theworkspacepathwillbeC:/Users/〈username>/workspace,asshowninthepreviousillustration.However,foranynumberofreasons,youmaywanttounchecktheUseDefaultLocationcheckboxandselectadifferentlocat(yī)ionforyouject.Onereasonyoumaywanttospecifyadifferentlocationhereissimplyifyouwanttochoosealocat(yī)ionforthisspecificprojectthat(yī)isseparatefromotherAndroidprojects.Forexample,youmaywanttokeeptheprojectsthatyoucreateinthisbookinadifferentlocationfromprojectsthatyoucreat(yī)einthefutureonyourown.Ifso,simplyoverridetheLocationoptiontospecifyyourowncustomlocationdireject.實訓報告實訓項目名稱基于Android計算器的開發(fā)與測試二級學院信息工程學院專業(yè)班級11級姓名學號日期2014—11-19項目名稱基于安卓計算器的開發(fā)與測試地點教13603報告內(nèi)容在本報告中,我們主要介紹了國內(nèi)目前手機系統(tǒng)和軟件的現(xiàn)狀和發(fā)展,針對這方面我們設(shè)計了基于Android計算器。報告內(nèi)容大致分為三個部分。第一部分首先介紹了需求分析,其中介紹了計算器最基本的功能.之后還有一些按鍵的設(shè)置以及計算器的基本功能。第二部分我們介紹了關(guān)于計算器的總體設(shè)計和詳細設(shè)計其中我們用了兩個流程圖來表示,分別是程序設(shè)計流程圖和軟件設(shè)計流程圖。然后還包含了計算器模塊的設(shè)計。第三部分為計算器的測試部分,其中我們對計算器進行了多方的測試。此外還有測試用例圖。教師評語成績:教師簽名:摘要Android是當今最重要的手機開發(fā)平臺之一,它是建立在Java基礎(chǔ)之上的,能夠迅速建立手機軟件的解決方案。Android的功能十分強大,成為當今軟件行業(yè)的一股新興力量。Android基于Linux平臺,由操作系統(tǒng)、中間件、用戶界面和應(yīng)用軟件組成,具有以下5個特點:開放性、應(yīng)用程序無界限、應(yīng)用程序是在平等條件下創(chuàng)建的,應(yīng)用程序可以輕松的嵌入網(wǎng)絡(luò)、應(yīng)用程序可以并行運行.而簡單計算器又是手機上必備的小程序,所以此次創(chuàng)新實踐很有意義。并且具有很強的使用性。關(guān)鍵字:計算器,Android,移動設(shè)備目錄TOC\o”1-3"\h\uHYPERLINKfirstFlag=false;//改變首次輸入的標記}}else{if(!clearFlag){//如果flag=false不需要清空顯示區(qū)的值,就調(diào)用方法計算jsp(Double.parseDouble(editText.getText()。toString()));//保存顯示區(qū)域的值,并計算}//保存你點擊的運算符lastCommand=inputCommand;clearFlag=true;//因為我這里已經(jīng)輸入過運算符,}}}加、減、乘、除等各種計算功能的實現(xiàn):privat(yī)evoidjsp(doublex){if(lastCommand。equals("+”)){result+=x;}elseif(lastCommand。equals(”-”)){result—=x;}elseif(lastCommand.equals("*")){result*=x;}elseif(lastCommand.equals(”/")){result/=x;}elseif(lastCommand。equals("=")){result=x;}editText.setText(””+result);}}5測試用列和結(jié)果5。1測試用列通過以下的測試用例進行對游戲各功能模塊的測試并加以修改,如表5.1所示。測試編號測試輸入期望結(jié)果實際結(jié)果11+23。03.021*22.02.031/20。50.541/0無結(jié)果錯誤51—(-3)4.0-2。06--2程序錯誤程序錯誤表5.1測試用例表5。2測試用列展示圖1.測試1+2時的狀態(tài)如圖5.2所示:圖5。2測試結(jié)果圖2.測試1*2時如圖5.3所示:圖5.3測試結(jié)果圖3.測試1/2時如圖5.4所示:圖5.4測試結(jié)果圖測試1/0時如圖5.5所示:圖5.5測試結(jié)果圖5。測試1-(—3)如圖5。6所示:圖5.6測試結(jié)果圖6.測試輸入--2時如圖5。7所示:圖5。7測試結(jié)果圖6小結(jié)這次項目android計算器項目設(shè)計是在eclipse平臺下設(shè)計,到現(xiàn)在為止,該系統(tǒng)的功能基本符合了普通計算器的要求,整個系統(tǒng)界面簡單明了,使用起來十分方便,具有普通計算器的基本功能,同時拓展了一些普通計算器上沒有的部分科學計算功能。在整個開發(fā)過程中,從需求分析到總體架構(gòu)的構(gòu)思,到最后代碼的編寫我投入了大量的時間和精力,對系統(tǒng)中的每個功能都進行了反復的調(diào)試,修改。因為這是我是第一次系統(tǒng)性的進行軟件的開發(fā),不論是在知識層面、開發(fā)平臺的使用層面還是經(jīng)驗方面都有著很大的欠缺和不足,因此本軟件難免會有一些功能不完善、界面不美觀等一些不盡如人意的地方,但是再短短一個星期的時間內(nèi),我已經(jīng)進行了很大的努力。通過這個android計算器項目設(shè)計,我不經(jīng)鞏固了我們在書本上學到和平時老師傳授的知識,而且還學到了許多書本上學不到的知識,并運用了網(wǎng)絡(luò)這個平臺查詢一些不明白的知識點。指導老師在我軟件代碼編寫和后期軟件調(diào)試期間,給我很大的幫助。要謝謝各位幫過我的老師和同學。這次的實驗讓我對我的學過的知識有了深一步的了解。參考文獻[1]劉敏.
移動終端的Android移植與應(yīng)用程序設(shè)計[D].西安電子科技大學2011[2]王蕾.
哈爾濱招行Android手機銀行匯率換算模塊的設(shè)計與實現(xiàn)[D].吉林大學2011[3]施金蘭.
基于Android平臺的網(wǎng)絡(luò)共享研究與實現(xiàn)[D]。華東師范大學2011[4]趙建勛.
基于Android平臺的移動位置服務(wù)的開發(fā)與實現(xiàn)[J]?,F(xiàn)代商貿(mào)工業(yè)。2010(20)[5]李林濤,朱珊虹?;贏ndroid系統(tǒng)的手機游戲黑白棋的設(shè)計與實現(xiàn)[J]。新鄉(xiāng)學院學報(自然科學版).2011(03)[6]叢秋波。用于Android手機操作系統(tǒng)的視頻引擎[J].電子設(shè)計技術(shù)。2010(07)[7]王豐,付明棟,馮海亮,施玉海.智能終端圖形用戶界面設(shè)計與實現(xiàn)[J].廣播電視信息。2011(08)[8]溫敏,艾麗蓉,王志國。Android智能手機系統(tǒng)中文件實時監(jiān)控的研究與實現(xiàn)[J]??茖W技術(shù)與工程。2009(07)[9]劉牛.
基于Android平臺的數(shù)字電視機頂盒模擬器的研究與開發(fā)[D]。蘭州大學2012[10]王康.
AndroidRIL研究及其在無線通訊模塊上的實現(xiàn)[D].太原科技大學2012附錄:<?xmlversion=”1。0”encoding="utf-8"?><TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height=”wrap_content"android:textSize=”42sp”android:stretchColumns="1"〉<TableRow>〈EditTextandroid:id="@+id/result”android:layout_width="fill_parent"android:layout_height=”wrap_content”android:background="@android:drawable/editbox_background"android:layout_span="4"android:textSize="48sp"android:gravity="right|center_vertical"android:cursorVisible="false”android:editable=”false"android:lines="1"/>〈/TableRow><TableRowandroid:orientation="horizontal"android:layout_width="fill_parent”android:layout_height=”wrap_content”android:textSize=”42sp"android:layout_weight=”1”〉<Buttonandroid:id=”@+id/num7"android:layout_width="fill_parent"android:layout_height="wrap_content"android:textSize="42sp”android:text=”@string/setText"android:layout_weight="1"/>〈Buttonandroid:id=”@+id/num8”android:layout_width="fill_parent”android:layout_height=”wrap_content"android:textSize="42sp"android:text=”@string/a"android:layout_weight="1"/>〈Buttonandroid:id="@+id/num9"android:layout_width=”fill_parent"android:layout_height="wrap_content"android:textSize=”42sp”android:text=”@string/b”android:layout_weight="1”/><Buttonandroid:id="@+id/divide”android:layout_width=”fill_parent"android:layout_height=”wrap_content"android:textSize=”42sp"android:text="@string/n"android:layout_weight="1"/〉</TableRow〉<TableRowandroid:orientation=”horizontal”android:layout_width="fill_parent"android:layout_height="wrap_content"android:textSize=”42sp"android:layout_weight=”1”>〈Buttonandroid:id=”@+id/num4"android:layout_width=”fill_parent"android:layout_height="wrap_content”android:textSize="42sp"android:text=”@string/c"android:layout_weight="1"/〉〈Buttonandroid:id=”@+id/num5”android:layout_width=”fill_parent”android:layout_height=”wrap_content"android:textSize="42sp”android:text="@string/d"android:layout_weight=”1”/〉〈Buttonandroid:id="@+id/num6"android:layout_width=”fill_parent”android:layout_height="wrap_content"android:textSize="42sp"android:text="@string/e"android:layout_weight="1"/〉〈Buttonandroid:id=”@+id/multiply"android:layout_width=”fill_parent"android:layout_height="wrap_content"android:textSize="42sp”android:text="@string/m"android:layout_weight="1"/〉〈/TableRow>〈TableRowandroid:orientation="horizontal"android:layout_width=”fill_parent”android:layout_height=”wrap_content"android:textSize=”42sp”android:layout_weight="1"〉<Buttonandroid:id="@+id/num1”android:layout_width="fill_parent"android:layout_height=”wrap_content"android:textSize=”42sp"android:text=”@string/f”android:layout_weight="1”/>〈Buttonandroid:id="@+id/num2”android:layout_width="fill_parent”android:layout_height="wrap_content”android:textSize="42sp"android:text=”@string/g"android:layout_weight=”1"/〉<Buttonandroid:id=”@+id/num3"android:layout_width="fill_parent"android:layout_height="wrap_content”android:textSize="42sp”android:text="@string/h"android:layout_weight="1"/>〈Buttonandroid:id="@+id/subtract"android:layout_width=”fill_parent"android:layout_height=”wrap_content”android:textSize=”42sp"android:text="@string/k”android:layout_weight="1"/></TableRow〉<TableRowandroid:orientat(yī)ion="horizontal"android:layout_width="fill_parent"android:layout_height="wrap_content"android:textSize="42sp"android:layout_weight=”1”〉<Buttonandroid:id="@+id/num0”android:layout_width=”fill_parent"android:layout_height="wrap_content"android:textSize=”42sp”android:text=”@string/i"android:layout_weight=”1"/〉<Buttonandroid:id="@+id/point”android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight=”1"android:minHeight="48dip"android:text="@string/q"android:textSize="42sp"/>〈Buttonandroid:id=”@+id/add"android:layout_width="fill_parent"android:layout_height="wrap_content"android:textSize="42sp"android:text="@string/j”android:layout_weight="1”/〉<Buttonandroid:id="@+id/equal"android:layout_width="fill_parent"android:layout_height="wrap_content"android:textSize="42sp"android:text="@string/w"android:layout_weight=”1"/></TableRow><TableRow><Buttonandroid:id=”@+id/clear”android:layout_width=”fill_parent"android:layout_height=”wrap_content”android:textSize=”30sp”android:text=”@string/s"android:layout_span="4”android:gravity="center_vertical|center_horizontal"/></TableRow〉〈/TableLayout〉packagecom.example;importandroid.app.Activity;importandroid。os.Bundle;importandroid。view。View;importandroid.view。View.OnClickListener;importandroid.widget。Button;importandroid.widget。EditText;publicclassMainActivityextendsActivity{privateButton[]btnNum=newButton[11];//數(shù)值按鈕privateButton[]btnCommand=newButton[5];//符號按鈕privateEditTexteditText=null;//顯示區(qū)域privat(yī)eButtonbtnClear=null;//clear按鈕privateStringlastCommand;//用于保存運算符privatebooleanclearFlag;//用于判斷是否清空顯示區(qū)域的值,true需要,false不需要privatebooleanfirstFlag;//用于判斷是否是首次輸入,true首次,false不是首次privatedoubleresult;//計算結(jié)果publicMainActivity(){//初始化各項值result=0;//x的值firstFlag=true;//是首次運算clearFlag=false;//不需要清空lastCommand=”=”;//運算符}@OverridepublicvoidonCreate(BundlesavedInstanceState){super。onCreate(savedInstanceState);setContentView(R.layout.activity_main);//獲取運算符btnCommand[0]=(Button)findViewById(R。id.add);btnCommand[1]=(Button)findViewById(R。id。subtract);btnCommand[2]=(Button)findViewById(R。id。multiply);btnCommand[3]=(Button)findViewById(R。id.divide);btnCommand[4]=(Button)findViewById(R.id。equal);//獲取數(shù)字btnNum[0]=(Button)findViewById(R。id。num0);btnNum[1]=(Button)findViewById(R。id.n
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 專題2.9 函數(shù)的零點(原卷版)-2024年高考數(shù)學一輪復習精講精練寶典(新高考專用)
- 2022年北京市石景山初三二模英語試卷及答案
- (一模)萍鄉(xiāng)市2025年高三第一次模擬考試生物試卷(含答案解析)
- 2020-2021深圳寶文學校小學三年級數(shù)學下期中第一次模擬試卷(及答案)
- 機井電力配套施工方案
- 關(guān)于活動付款合同范例
- 專利委托合同范例
- 化工勞務(wù)合同范例
- 保安工作總結(jié)計劃裝飾行業(yè)保安工作的工地保護
- 會計工作與企業(yè)發(fā)展的關(guān)系計劃
- 南充市高2025屆高三高考適應(yīng)性考試(二診)英語試卷
- 2025年湖南有色金屬職業(yè)技術(shù)學院單招職業(yè)傾向性測試題庫附答案
- 第五章產(chǎn)前檢查及高危妊娠監(jiān)測課件
- 《人工智能基礎(chǔ)》課件-AI的前世今生:她從哪里來
- 《防止電力建設(shè)工程施工安全事故三十項重點要求》
- 外研版九年級英語下冊Module-4-Unit-2教學課件(PPT 16頁)
- 精品隨班就讀個別化教學計劃
- 第一章 - 免疫規(guī)劃信息管理系統(tǒng)
- 初中語文四大名著選擇題精選48道(修訂版帶答案)
- 下肢血管超聲規(guī)范檢查與診斷(精品)
- 職業(yè)駕駛員職業(yè)心理和生理健康
評論
0/150
提交評論