Cov txheej txheem:

Yuav Ua Li Cas Tsim Android App Nrog Android Studio: 8 Kauj Ruam (nrog Duab)
Yuav Ua Li Cas Tsim Android App Nrog Android Studio: 8 Kauj Ruam (nrog Duab)

Video: Yuav Ua Li Cas Tsim Android App Nrog Android Studio: 8 Kauj Ruam (nrog Duab)

Video: Yuav Ua Li Cas Tsim Android App Nrog Android Studio: 8 Kauj Ruam (nrog Duab)
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Yuav Ua Li Cas Tsim Android App Nrog Android Studio
Yuav Ua Li Cas Tsim Android App Nrog Android Studio

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

Nruab Android Studio
Nruab Android Studio
Nruab Android Studio
Nruab Android Studio
  1. Mus rau https://developer.android.com/sdk/index.html mus rub Android Studio.
  2. Siv lub installer los nruab Android Studio ua raws nws cov lus qhia.

Kauj Ruam 2: Qhib Txoj Haujlwm Tshiab

Qhib Txoj Haujlwm Tshiab
Qhib Txoj Haujlwm Tshiab
Qhib Txoj Haujlwm Tshiab
Qhib Txoj Haujlwm Tshiab
Qhib Txoj Haujlwm Tshiab
Qhib Txoj Haujlwm Tshiab
  1. Qhib Android Studio.
  2. Hauv qab "Pib Pib" cov ntawv qhia zaub mov, xaiv "Pib qhov tshiab Android Studio project."
  3. Ntawm qhov "Tsim Txoj Haujlwm Tshiab" qhov rai uas qhib, sau koj qhov haujlwm "HelloWorld".
  4. Yog tias koj xaiv, teeb lub tuam txhab npe raws li xav tau*.
  5. Nco ntsoov qhov project qhov chaw nyob qhov twg thiab hloov nws yog xav tau.
  6. Nyem "Tom ntej."
  7. Nco ntsoov tias "Xov tooj thiab Tablet" tsuas yog lub npov uas tau khij.
  8. 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.
  9. Nyem "Tom ntej."
  10. Xaiv "Blank Activity."
  11. Nyem "Tom ntej."
  12. Tawm ntawm txhua qhov Kev Ua Haujlwm lub npe raws li lawv muaj.
  13. 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

Hloov Kho Cov Lus Txais Tos hauv Cov Haujlwm Tseem Ceeb
Hloov Kho Cov Lus Txais Tos hauv Cov Haujlwm Tseem Ceeb
Hloov Kho Cov Lus Txais Tos hauv Cov Haujlwm Tseem Ceeb
Hloov Kho Cov Lus Txais Tos hauv Cov Haujlwm Tseem Ceeb
  1. Nkag mus rau qhov chaw activity_main.xml yog tias nws tseem tsis tau qhib.
  2. Nco ntsoov tias Tsim tab qhib rau ntawm activity_main.xml zaub.
  3. 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.
  4. Hauv qhov project file system ntawm sab laug ntawm lub qhov rais, qhib cov ntawv tais ceev tseg.
  5. Hauv daim nplaub tshev qhov tseem ceeb, ob-nias cov ntawv strings.xml.
  6. Hauv cov ntawv no, nrhiav kab "Nyob zoo ntiaj teb!".
  7. Tom qab "Nyob zoo ntiaj teb!" lus, ntxiv "Zoo siab txais tos rau kuv app!"
  8. Rov qab mus rau qhov chaw activity_main.xml.
  9. 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

Ntxiv Khawm rau Cov Haujlwm Tseem Ceeb
Ntxiv Khawm rau Cov Haujlwm Tseem Ceeb
Ntxiv Khawm rau Cov Haujlwm Tseem Ceeb
Ntxiv Khawm rau Cov Haujlwm Tseem Ceeb
  1. Nkag mus rau Tus Tsim Tsim tab ntawm kev ua haujlwm_main.xml zaub.
  2. Hauv Palette cov ntawv qhia zaub mov sab laug ntawm lub xov tooj, nrhiav khawm (hauv qab nqe lus Widgets).
  3. Nyem thiab luag khawm kom nyob hauv qab koj cov lus txais tos.
  4. Nco ntsoov tias koj lub pob tseem raug xaiv.
  5. Hauv Cov Ntawv Qhia Khoom (nyob rau sab xis ntawm lub qhov rais), nqes mus kom pom daim teb rau "ntawv".
  6. Hloov cov ntawv sau los ntawm "New Button" mus rau "Next Page."

Kauj Ruam 5: Tsim Kev Ua Zaum Ob

Tsim Yam Kev Ua Zaum Ob
Tsim Yam Kev Ua Zaum Ob
Tsim Yam Ob Yam
Tsim Yam Ob Yam
Tsim Yam Kev Ua Zaum Ob
Tsim Yam Kev Ua Zaum Ob
  1. Nyob rau sab saum toj ntawm txoj haujlwm cov kab ntawv system tsob ntoo, nyem rau ntawm "app."
  2. Nkag mus rau Tshiab> Kev Ua Haujlwm> Tsis Ua Haujlwm.
  3. Hloov lub npe ntawm qhov haujlwm no mus rau "SecondActivity".
  4. Nyem "Ua tiav."
  5. Nco ntsoov tias koj nyob hauv Tsim saib ntawm activity_second.xml.
  6. 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.
  7. Nrog lub thawv ntawv tseem raug xaiv, nrhiav "id" teb hauv Cov Ntawv Qhia Khoom ntawm sab xis, thiab teeb nws rau "text2".
  8. Qhib strings.xml dua.
  9. Ntxiv kab tshiab hauv qab "Nyob zoo ntiaj teb! Txais tos rau kuv li app!" uas nyeem "Txais tos rau nplooj ntawv thib ob!".
  10. Rov qab mus rau activity_second.xml.
  11. Xaiv lub thawv ntawv dua.
  12. Hauv Cov Khoom Vaj Huam Sib Luag, teeb tsa "ntawv" teb rau "@string/second_page".
  13. 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

Sau lub khawm
Sau lub khawm
Sau lub khawm
Sau lub khawm
Sau lub khawm
Sau lub khawm

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

Kuaj Daim Ntawv Thov
Kuaj Daim Ntawv Thov
Kuaj Daim Ntawv Thov
Kuaj Daim Ntawv Thov
  1. Nyem lub cim ntsuab ua si los ntawm lub cuab yeej nyob rau sab saum toj ntawm Android Studio qhov rai.
  2. Thaum qhov "Xaiv Ntaus" cov lus sib tham tshwm (qhov no yuav siv sijhawm me ntsis), xaiv qhov "Lauch emulator" xaiv.
  3. Nyem OK.
  4. 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.
  5. 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

Up, Up, thiab Tawm mus!
Up, Up, thiab Tawm mus!
Up, Up, thiab Tawm mus!
Up, Up, 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: