Android Activity & Fragment Tutorial 39 - Fragment LifeCycle

preview_player
Показать описание
Android Fragment is the part of an activity, it is also known as sub-activity. There can be more than one fragment in an activity. Fragments represent multiple screen inside one activity.

The lifecycle of android fragment is like the activity lifecycle.
There are 12 lifecycle methods for fragment.
1) onAttach(Activity) - it is called only once when it is attached with activity.
2) onCreate - It is used to initialize the fragment.
3) onCreateView - creates and returns view hierarchy.
4) onActivityCreated - It is invoked after the completion of onCreate() method.
5) onViewStateRestored - It provides information to the fragment that all the saved state of fragment view hierarchy has been restored.
6) onStart() - makes the fragment visible.
7) onResume() - makes the fragment interactive.
8) onPause() - is called when fragment is no longer interactive.
9) onStop() - is called when fragment is no longer visible.
10) onDestroyView() - allows the fragment to clean up resources.
11) onDestroy() - allows the fragment to do final clean up of fragment state.
12) onDetach() - It is called immediately prior to the fragment no longer being associated with its activity.

Please do like, share and subscribe/follow these pages

Рекомендации по теме
Комментарии
Автор

To the point. Did not show onDestroy(), onDestroyView() though

kirancnayakdeptofcs
welcome to shbcf.ru