Dab tsi yog onActivityCreated hauv Android?
Dab tsi yog onActivityCreated hauv Android?

Video: Dab tsi yog onActivityCreated hauv Android?

Video: Dab tsi yog onActivityCreated hauv Android?
Video: Hmong new song 2016 - Yog dab tsi - Xub Hluav Taws (Official MV) 2024, Kaum ib hlis
Anonim

onActivityCreated ():

Raws li lub npe hais, qhov no yog hu ua tom qab Kev Ua Haujlwm 's onCreate() tau ua tiav. Nws yog hu ua tom qab onCreateView(), thiab feem ntau yog siv rau qhov kawg pib (piv txwv li, hloov kho UI ntsiab).

Ib yam li ntawd, nws tau nug, dab tsi yog onCreateView hauv Android?

Android Fragment onCreateView () onCreateView () txoj kev tau txais LayoutInflater, ViewGroup thiab Bundle raws li qhov tsis muaj. Thaum koj dhau qhov tsis tseeb raws li qhov kawg parameter rau inflate(), niam txiv ViewGroup tseem siv rau kev xam cov lej ntawm inflated View, yog li koj tsis tuaj yeem hla tsis tau raws li niam txiv ViewGroup.

Tom qab ntawd, lo lus nug yog, dab tsi yog tawg hauv Android? A tawg tawg yog ib qho kev ywj pheej Android tivthaiv uas tuaj yeem siv los ntawm kev ua haujlwm. A tawg tawg encapsulates functionality kom nws yooj yim dua rau rov siv dua nyob rau hauv kev ua ub no thiab layouts. A tawg tawg khiav hauv cov ntsiab lus ntawm ib qho kev ua ub no, tab sis nws muaj nws lub neej voj voog thiab feem ntau nws tus kheej siv interface.

Hais txog qhov no, siv qhov kawg () hauv Android yog dab tsi?

Ua tiav () txoj kev yuav rhuav tshem cov haujlwm tam sim no. Koj ua tau siv hom no nyob rau hauv rooj plaub thaum koj tsis xav kom cov haujlwm no thauj khoom dua thiab dua thaum tus neeg siv nias rov qab khawm. Yeej nws clears cov dej num los ntawm lub. pawg tam sim no.

Qhov txawv ntawm onCreate thiab onCreateView yog dab tsi?

onCreate yog hu ua thawj creation ntawm qhov tawg. Koj ua koj cov tsis graphical pib ntawm no. Nws ua tiav txawm tias ua ntej qhov layout yog inflated thiab cov fragment yog pom. onCreateView yog hu ua inflate lub layout ntawm cov fragment i.e graphical initialization feem ntau tshwm sim ntawm no.

Pom zoo: