Cov txheej txheem:
- Kauj ruam 1: Nruab Android Studio
- Kauj Ruam 2: Qhib Txoj Haujlwm Tshiab
- Kauj Ruam 3: Hloov Kho Cov Lus Txais Tos hauv Cov Haujlwm Tseem Ceeb
- Kauj Ruam 4: Ntxiv Khawm rau Cov Haujlwm Tseem Ceeb
- Kauj Ruam 5: Tsim Kev Ua Zaum Ob
- Kauj Ruam 6: Sau Khawm "onClick" Txoj Kev
- Kauj Ruam 7: Xeem Daim Ntawv Thov
- Kauj Ruam 8: Nce, nce, thiab Tawm mus
Video: Yuav Ua Li Cas Tsim Android App Nrog Android Studio: 8 Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Cov ntawv qhia no yuav qhia koj cov hauv paus ntawm yuav tsim Android app siv Android Studio kev txhim kho ib puag ncig. Raws li Android cov cuab yeej ua ntau zuj zus, kev thov rau cov apps tshiab yuav tsuas yog nce ntxiv. Android Studio yog qhov yooj yim siv (thiab pub dawb) ib puag ncig kev txhim kho kom kawm paub. Nws zoo tshaj yog tias ib tus muaj kev paub ua haujlwm ntawm Java programming lus rau qhov kev qhia no vim nws yog cov lus siv los ntawm Android. Yuav tsis muaj ntau txoj cai siv hauv qhov kev qhia no, yog li kuv yuav xav tias koj paub Java txaus los nkag siab lossis txaus siab saib qhov koj tsis paub. Qhov no yuav siv sijhawm kwv yees li 30-60 feeb, nyob ntawm qhov nrawm koj tuaj yeem rub tawm thiab teeb tsa Android Studio. Tom qab siv qhov kev qhia no los tsim koj thawj Android app, koj yuav zoo ntawm koj txoj hauv kev kom muaj kev lom zem tshiab yam nyiam lossis tej zaum txawm tias muaj kev cia siab ua haujlwm hauv kev txhim kho mobile.
Kauj ruam 1: Nruab Android Studio
- Mus rau https://developer.android.com/sdk/index.html mus rub Android Studio.
- Siv lub installer los nruab Android Studio ua raws nws cov lus qhia.
Kauj Ruam 2: Qhib Txoj Haujlwm Tshiab
- Qhib Android Studio.
- Hauv qab "Pib Pib" cov ntawv qhia zaub mov, xaiv "Pib qhov tshiab Android Studio project."
- Ntawm qhov "Tsim Txoj Haujlwm Tshiab" qhov rai uas qhib, sau koj qhov haujlwm "HelloWorld".
- Yog tias koj xaiv, teeb lub tuam txhab npe raws li xav tau*.
- Nco ntsoov qhov project qhov chaw nyob qhov twg thiab hloov nws yog xav tau.
- Nyem "Tom ntej."
- Nco ntsoov tias "Xov tooj thiab Tablet" tsuas yog lub npov uas tau khij.
- Yog tias koj tab tom npaj los sim lub app hauv koj lub xov tooj, nco ntsoov tias yam tsawg kawg SDK qis dua koj lub xov tooj kev ua haujlwm.
- Nyem "Tom ntej."
- Xaiv "Blank Activity."
- Nyem "Tom ntej."
- Tawm ntawm txhua qhov Kev Ua Haujlwm lub npe raws li lawv muaj.
- Nyem "Ua tiav."
*Nco tseg: Nws yog lub npe sib tham hauv cov haujlwm hauv Android los teeb tsa lub tuam txhab npe raws li qee yam ntawm "piv txwv.name.here.com".
Kauj Ruam 3: Hloov Kho Cov Lus Txais Tos hauv Cov Haujlwm Tseem Ceeb
- Nkag mus rau qhov chaw activity_main.xml yog tias nws tseem tsis tau qhib.
- Nco ntsoov tias Tsim tab qhib rau ntawm activity_main.xml zaub.
- Nyem thiab luag tus "Nyob zoo, ntiaj teb!" los ntawm kaum sab saud sab saud ntawm lub xov tooj tso rau nruab nrab ntawm lub vijtsam.
- Hauv qhov project file system ntawm sab laug ntawm lub qhov rais, qhib cov ntawv tais ceev tseg.
- Hauv daim nplaub tshev qhov tseem ceeb, ob-nias cov ntawv strings.xml.
- Hauv cov ntawv no, nrhiav kab "Nyob zoo ntiaj teb!".
- Tom qab "Nyob zoo ntiaj teb!" lus, ntxiv "Zoo siab txais tos rau kuv app!"
- Rov qab mus rau qhov chaw activity_main.xml.
- Nco ntsoov tias koj cov ntawv sau tam sim no nyeem "Nyob zoo ntiaj teb! Zoo siab txais tos rau kuv li app!"
Kauj Ruam 4: Ntxiv Khawm rau Cov Haujlwm Tseem Ceeb
- Nkag mus rau Tus Tsim Tsim tab ntawm kev ua haujlwm_main.xml zaub.
- Hauv Palette cov ntawv qhia zaub mov sab laug ntawm lub xov tooj, nrhiav khawm (hauv qab nqe lus Widgets).
- Nyem thiab luag khawm kom nyob hauv qab koj cov lus txais tos.
- Nco ntsoov tias koj lub pob tseem raug xaiv.
- Hauv Cov Ntawv Qhia Khoom (nyob rau sab xis ntawm lub qhov rais), nqes mus kom pom daim teb rau "ntawv".
- Hloov cov ntawv sau los ntawm "New Button" mus rau "Next Page."
Kauj Ruam 5: Tsim Kev Ua Zaum Ob
- Nyob rau sab saum toj ntawm txoj haujlwm cov kab ntawv system tsob ntoo, nyem rau ntawm "app."
- Nkag mus rau Tshiab> Kev Ua Haujlwm> Tsis Ua Haujlwm.
- Hloov lub npe ntawm qhov haujlwm no mus rau "SecondActivity".
- Nyem "Ua tiav."
- Nco ntsoov tias koj nyob hauv Tsim saib ntawm activity_second.xml.
- Luag lub npov ntawv nyob rau sab saud sab laug ntawm lub xov tooj tso rau hauv nruab nrab ib yam li koj tau ua ntawm Qhov Kev Ua Haujlwm Loj.
- Nrog lub thawv ntawv tseem raug xaiv, nrhiav "id" teb hauv Cov Ntawv Qhia Khoom ntawm sab xis, thiab teeb nws rau "text2".
- Qhib strings.xml dua.
- Ntxiv kab tshiab hauv qab "Nyob zoo ntiaj teb! Txais tos rau kuv li app!" uas nyeem "Txais tos rau nplooj ntawv thib ob!".
- Rov qab mus rau activity_second.xml.
- Xaiv lub thawv ntawv dua.
- Hauv Cov Khoom Vaj Huam Sib Luag, teeb tsa "ntawv" teb rau "@string/second_page".
- Nco ntsoov tias lub npov ntawv tam sim no nyeem "Txais tos rau nplooj ntawv thib ob!" thiab nyob hauv nruab nrab ntawm lub vijtsam hauv lub xov tooj.
Kauj Ruam 6: Sau Khawm "onClick" Txoj Kev
Xaiv lub MainActivity.java tab nrog rau sab saum toj ntawm ib puag ncig ua haujlwm
2. Ntxiv cov kab hauv qab no ntawm qhov kawg ntawm onCreate txoj kev:
Khawm khawm = (Khawm) findViewById (R.id.button);
button.setOnClickListener (View.onClickListener tshiab () {
pej xeem void onClick (Saib v) {
goToSecondActivity ();
}
});
3. Ntxiv cov txheej txheem hauv qab no mus rau hauv qab ntawm MainActivity chav kawm:
ntiag tug tsis muaj dab tsi goToSecondActivity () {
Kev mob siab rau = Intent tshiab (qhov no, SecondActivity.class);
startActivity (txhob txwm);
}
4. Nyem rau + txuas ntxiv rau ntshuam ntawm kab thib peb ntawm MainActivity.java txhawm rau nthuav cov lus tshaj tawm.
5. Ntxiv cov lus hauv qab no mus rau qhov kawg ntawm cov lus hais tawm yog tias lawv tseem tsis tau muaj:
ntshuam android.content. Intent;
ntshuam android.view. View;
ntshuam android.widget. TextView;
Kauj Ruam 7: Xeem Daim Ntawv Thov
- Nyem lub cim ntsuab ua si los ntawm lub cuab yeej nyob rau sab saum toj ntawm Android Studio qhov rai.
- Thaum qhov "Xaiv Ntaus" cov lus sib tham tshwm (qhov no yuav siv sijhawm me ntsis), xaiv qhov "Lauch emulator" xaiv.
- Nyem OK.
- Thaum lub emulator qhib (qhov no ib yam tuaj yeem siv sijhawm ib ntus), lub app yuav cia li tso lub app thaum lub xov tooj virtual tau qhib.
- Nco ntsoov tias txhua qhov ntawm koj cov ntawv pom raug thiab tias lub pob coj koj mus rau nplooj ntawv tom ntej.
Kauj Ruam 8: Nce, nce, thiab Tawm mus
Nrog koj zoo siab! Tam sim no koj tau ua tiav koj thawj daim ntawv thov Android nrog qee qhov ua haujlwm yooj yim. Koj daim ntawv thov tiav yuav tsum muaj nplooj ntawv tos txais tus neeg siv thiab lub pob uas coj tus neeg siv mus rau nplooj ntawv thib ob.
Txij ntawm no koj muaj kev paub tsis txaus koj yuav tsum tau mus kawm txhua yam muaj kom paub txog kev txhim kho daim ntawv thov Android.
Pom zoo:
Yuav Ua Li Cas Tsim Linux Boot Drive (thiab Yuav Siv Li Cas): 10 Cov Kauj Ruam
Yuav Ua Li Cas Tsim Linux Boot Drive (thiab Yuav Siv Li Cas): Nov yog cov lus qhia yooj yim yuav pib li cas nrog Linux, tshwj xeeb yog Ubuntu
YUAV UA LI CAS YUAV UA LI CAS YUAV TSUM ROBOT COOB SCARECROW: 16 Cov Kauj Ruam (nrog Duab)
YUAV UA LI CAS YUAV TSUM NYOB ROBOT COW SCARECROW: Kuv nyuam qhuav tsim Moo-Bot, tus neeg hlau nyuj scarecrow dhia hla lub hli, rau kev sib tw hauv zej zog scarecrow.Kuv kev tshoov siab yog los ntawm kuv tus tub hu nkauj "hey diddle diddle, miv thiab fiddle. .. " Txoj haujlwm zoo heev los ua haujlwm nrog kuv
YUAV UA LI CAS YUAV UA LI CAS NYOB ZOO TSHAJ PLAWS NROG IR IR LIGHT: 5 Kauj Ruam (nrog Duab)
YUAV UA LI CAS Ua Ib Lub Koob Yees Duab Tsis Muaj IR IR LIGHT: Kuv tau pom lub koob yees duab Infrared thiaj li siv nws hauv lub kaw lus kaw suab. Nrog nws koj tseem tuaj yeem tau txais cov duab txias no: cov khoom ci hauv lub zeem muag lub koob yees duab uas ib txwm muaj nyob hauv qhov tseeb. Koj tuaj yeem tau txais cov txiaj ntsig zoo nkauj rau tus nqi pheej yig Nws
Yuav Ua Li Cas Tsim thiab Tsim Kev Sib Ntaus Neeg Hlau: 11 Kauj Ruam (nrog Duab)
Yuav Ua Li Cas Tsim thiab Tsim Kev Sib Ntaus Neeg Hlau: *NCO TSEG: vim Battlebots tau rov qab los ntawm huab cua cov lus qhia no tau txais ntau ntawm lub zog. Thaum ntau cov ntaub ntawv ntawm no tseem zoo, thov paub tias tau hloov pauv me ntsis hauv kev ncaws pob hauv 15 xyoos dhau los*Kev sib ntaus sib tua neeg hlau tau
Qhib Kev Tsim Khoom - (Yuav Ua Li Cas Tsim 30 (SERB) Cov Khoom Siv): 19 Cov Kauj Ruam (nrog Duab)
Qhib Kev Tsim Khoom - (Yuav Ua Li Cas Tsim 30 (SERB) Cov Khoom Siv): Zoo siab txais tos rau thawj qhov kev tawm tsam sab hauv oomlout.com lub Hoobkas. Ntawm oomlout peb tau tsom mus rau tsim "zoo siab lom zem qhib qhov khoom" qhov kev cog lus rau qhib qhov txuas mus rau peb cov txheej txheem tsim khoom ib yam. Yog li dab tsi hauv qab no yog qib