Uhlelo lokusebenza
uhlu lokuhlola

    Oxhumana naye





    Ibhulogi yethu

    Sihlela ukubonakala kwakho! Ukusebenza okuhle nge-ONMA scout ukuthuthukiswa kohlelo lokusebenza lwe-android kuqinisekisiwe.

    Oxhumana naye
    ukuthuthukiswa kohlelo lokusebenza lwe-android

    Ibhulogi yethu


    Funda izisekelo zokuhlela ze-Android

    Uma ufuna ukufunda izisekelo ze-Android Programmierung, kukhona ezinye izinsiza ongazithola ku-inthanethi. Isifundo se-Android-Anfanger siqondiswe kubasebenzisi be-Java abanolwazi, ngakho-ke uzodinga ulwazi oluthile ngolimi. Kuzodinga futhi ukuzihlela. I-Android SDK akuyona into enkulu, kodwa udinga ukuqonda i-Java. Lesi sihloko sizokuhambisa kunqubo yokudala uhlelo lokusebenza olulula lwe-Android nokufunda indlela yokwenza i-shareActionProvider.

    Java

    Ukwakha i-Android-App ngokuvamile kusho ukusebenzisa ulimi lohlelo lwe-Java. Ukuze udale i-Android-App, uzodinga ithuluzi lokuthuthukisa uhlelo lokusebenza elibizwa ngokuthi i-Android-Studio. Isifundo esisekelwe ku-Java sizokufundisa mayelana nezingxenye ezihlukahlukene zohlelo lokusebenza lwe-Android, kuhlanganise izithombe, imisindo, ikhamera nezinzwa ezinyakazayo. Isifundo esisekelwe ku-Java sizokusiza futhi ukuthi uthuthukise izinhlelo zokusebenza zamawashi ahlakaniphile kanye nohlu oluhle kakhulu lwe-inthanethi. Ekugcineni, uzokwazi ukuthuthukisa izinhlelo zokusebenza zawo wonke lawa madivayisi futhi uwenze asebenze ngaphandle komthungo kudivayisi yakho.

    Ngaphezu kokufunda i-Java, ungafunda futhi ukuthi ungazakha kanjani izinhlelo zokusebenza eziyingxube usebenzisa i-Android SDK, ithuluzi lokuthuthukisa uhlelo lokusebenza. Leli thuluzi liqukethe i-Android SDK kanye ne-Interneti-teenused. Kuye ngezinga lakho lokuhlangenwe nakho, ungafunda ukuthuthukisa izinhlelo zokusebenza ezixubile ngokusebenzisa umakhi wohlelo lokusebenza. Le nketho ibiza kakhulu, kodwa ikuvumela ukuthi udale izinhlelo zokusebenza ngaphandle kokuhlela izinhlelo. Okuwukuphela kokubi ukuthi i-Java ayidumile njenge-Swift, I-Objective-C noma i-Swift.

    Njengoba uhlelo lokusebenza ku-Android lusekelwe ku-Linux, I-Java ulimi oluyinhloko olusetshenziselwa ukuthuthukisa izinhlelo zokusebenza. Ungalanda i-Java Studio ku-Google mahhala, kanye ne-Java SE Development Kit kanye ne-Runtime Environment (I-JVM) ukwakha uhlelo lwakho lokusebenza lwe-Android. I-Java iwulimi Lokuhlela Olugxile Entweni, futhi iwulimi lokuhlela oludume kakhulu lwe-Android. Empeleni, I-Java isetshenziselwa ukubhala izinhlelo zokusebenza zamadivayisi eselula. Futhi uma ufuna ukudala uhlelo lokusebenza lwe-iOS, ungafunda i-Swift ngaphandle kokufunda i-Java.

    I-XML-Parsing

    Uma usebenza kuhlelo lwe-Android, ungase ucabange ukuthi i-XML-Parsing ayidingekile. Empeleni, I-XML-Parsing iyadingeka ezimweni eziningi. Ulimi Lwemakhaphu Enwetshiwe (I-XML) ifomethi ejwayelekile yombhalo wekhodi yokwabelana ngolwazi ku-inthanethi. Izifunzo ze-XML zivame ukunikezwa amawebhusayithi avame ukubuyekeza okuqukethwe. Izinhlelo zokusebenza eziningi ezixhunywe kunethiwekhi kufanele zihlukanise idatha ye-XML ukuze zinikeze ulwazi kubasebenzisi bazo.

    Uhlelo lokusebenza lokuhlaziya lwe-XML luzoqoqa idatha futhi luyiguqule ibe iyunithi yezinhlamvu efomethiwe, engasetshenziswa ngezindlela eziningi. Ikilasi leqoqo, isizindalwazi, noma isizindalwazi yizo zonke izinketho. Iyunithi yezinhlamvu efomethiwe ewumphumela ifomethwe nge-HTML encane. Ezinye izindlela zingasebenza kangcono. Ikilasi langokwezifiso lingadingeka, njengoba isebenzisa i-GetResults() indlela yokuqoqa ukumelwa okuhlanganisiwe kwedatha.

    Uma umusha ohlelweni lwe-Android, ungase uzibuze ukuthi ungasebenzisa kanjani i-JSON noma i-XML. Ukuze usebenzise yangaphambili, uzodinga ukuba ne-Android Studio, kodwa ukubuyekezwa kwe-SDK API akusho lutho. Ukuze uqalise, ungabheka kuwebhusayithi Yonjiniyela be-Android ukuze uthole imiyalelo. Kufanele ukwazi ukuthola izibonelo eziyisisekelo zokuhlukanisa i-JSON ne-XML lapho.

    Umjikelezo Wokuphila Womsebenzi

    Kuhlelo lwe-Android, ungasebenzisa i-Activity Lifecycle ukuze ulawule ukuziphatha kohlelo lwakho lokusebenza. Lena inqubo lapho umsebenzi ubuyiselwa khona ngaphambili futhi usebenzisana nomsebenzisi. Ngenkathi isesimweni sokuqalwa kabusha, ihlala lapho kuze kususwe ukugxila kuyo, njengalapho umsebenzisi eshaya ucingo, ivala uhlelo lokusebenza, noma isikrini siyacisha. Ngenhlanhla, ungakwazi ukwengeza ukusebenza kokuqaphela i-lifecycle kuhlelo lwakho lokusebenza ukuze ulugcine lusebenza inqobo nje uma umsebenzisi ekwazi ukulibona.

    I-OnStart() indlela ibizwa lapho Umsebenzi usuzobonakala. Ilungiselela Umsebenzi wemisebenzi yokusebenzisana. Kubizwa ngaphambi kokuthi umsebenzi umiswe() futhi ku-Resume() izindlela. Le ndlela isetshenziselwa ukuqalisa izibuyekezo ze-UI nokulondoloza idatha yohlelo lokusebenza ngaphambi kokuba umsebenzi ubulawe isistimu. Ngaphezu kwalokho, i-OnPause() indlela ibizwa lapho okuthile kuthatha ukugxila komsebenzisi.

    Imisebenzi engasebenzi nayo ibizwa ngokuthi “engasebenzi” futhi yizo ezingabonakali kumsebenzisi. Uma isithonjana sohlelo lokusebenza sifihliwe, izongena esimweni sokumiswa isikhashana, futhi ngeke ibonakale ohlwini lwezinhlelo zokusebenza. Lesi simo ngokuvamile sifana nalapho umsebenzisi achofoza inkinobho yokuzulazula emuva. Uma ukubonakala komsebenzi kwehla ngaphansi komkhawulo othile, izobulawa.

    ShareActionProvider

    Uma ufuna indlela elula yokwabelana ngokuqukethwe ku-Android, ungase uthande ukucabanga ukusebenzisa i-ShareActionProvider. Leli klasi liyingxenye ye-Android Support Library, esekela izinguqulo ezindala ze-Android. I-Share-Apps yizinhlelo zokusebenza ezilula ezivumela abasebenzisi ukuthi babelane ngokuqukethwe phakathi kwezinhlelo zokusebenza ezimbili noma ngaphezulu. Ikilasi le-ShareActionProvider liyithuluzi eliwusizo lalezi zinhlelo zokusebenza. Ikhodi ewumsuka yaleli klasi ingatholakala lapha.

    Lesi sigaba sizibophezela ku-Action Bar menueintrag, noma Imenyu Yezinketho. Kubonakala njengesithonjana esiya kwesokudla. Uma isifakiwe, uhlelo luqala ngokuzenzakalelayo. Ungathola futhi i-ShareActionProvider kukhodi yomthombo ye-Android programmierung. Iboniswa njengesithonjana esiya kwesokudla futhi iqukethe uhlu lwezinhlelo zokusebenza ongabelana ngazo. Uma usungeze i-ShareActionProvider kuphrojekthi yakho, ungakwazi ke ukuyethula.

    I-ShareActionProvider yengezwe kuhlaka lwe-Android ku-ICS. Kwenza ukwabelana ngedatha phakathi kwezinhlelo zokusebenza ze-Android kube lula kakhulu. Igcwalisa uhlu lokubuka ngokwezifiso futhi yenze kube lula ukwengezwa kwemenyu yokwabelana ku-ActionBar. I-ShareActionProvider iphinde ibambe umhlinzeki ukuze ukwazi ukushintsha inhloso yayo uma ufuna ukwabelana. Lokhu kuwusizo ikakhulukazi uma usebenzisa i-ActionBar ukuze wabelane ngolwazi.

    Uchungechunge lwe-XML

    I-XML imele Ulimi Lwemakhaphu Olunwebekayo, futhi kuwulimi lwemakhaphu olulula olwasungulwa ekuqaleni ukuze lube Ulimi Lwemakhaphu Olujwayelekile Olujwayelekile (I-SGML). I-XML ichaza idatha enamathegi. Lolu limi lwemakhaphu luyakala futhi kulula ukuluthuthukisa, futhi isetshenziswa kabanzi kudatha ehlobene ne-UI ezinhlelweni ze-Android. Lesi sihloko sichaza izinto eziyisisekelo ze-XML futhi sibonisa ukuthi isetshenziswa kanjani ezinhlelweni ze-Android.

    I-XML-Parsing Methode

    I-XML-Parsing iwumsebenzi obalulekile wonjiniyela we-Android, ikakhulukazi uma uhlela ukuyisebenzisa ezinhlelweni zewebhu. Ifayela le-XML liqukethe ukulandelana kwemicimbi, abe esehlukaniswa futhi afomethwe abe umbhalo kanye nenye idatha. Kunezinhlobo ezintathu eziyinhloko zabahlaluli be-XML: I-SAX, I-DOM, futhi DONSELA. Ngayinye yalezi zindlela isebenzisa isethi yayo ehlukile yemithetho ukuphatha idatha nokuyihlaziya.

    Ngenkathi i-JSON isetshenziselwa kakhulu Izinkonzo Zewebhu, ezinye izinhlelo zokusebenza zisadinga ukuncozulula idatha ye-XML. Ngenhlanhla, kunezindlela ezimbalwa zokuhlaziya ezitholakalayo ze-Android, kufaka phakathi i-XML PullParser API. Ukudonsa kwe-XML kudinga inkumbulo encane kune-DOM Parser API. Kunomehluko ovamile phakathi kwalezi zindlela, kodwa ungasebenzisa noma yikuphi ukufeza umsebenzi ofanayo.

    I-DOM ingenye inketho ye-XML-pasing ku-Android. I-DOM inenkumbulo enkulu, kodwa ayinzima kakhulu kune-SAX. Uma umgomo wakho kuwukudala uhlelo lokusebenza oluzobonisa kuphela isethi engaphansi yokuphakelayo kwedatha, indlela ye-SAX ingase yanele. Uma uhlose ukuhlaziya amasethi edatha amakhulu ngokuzayo, nokho, ngaso sonke isikhathi kungcono ukusebenzisa indlela ye-DOM.

    ividiyo yethu
    Thola isilinganiso samahhala