What is fragment and its lifecycle Flashcards

1
Q

How is it related to activity

A

A fragment life cycle is closely related to the lifecycle of its host activity which means when the activity is in the pause state, all the fragments available in the activity will also stop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

onAttatch

A

 This method called first, To know that our fragment has been attached to an activity. We are passing the Activity that will host our fragment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

onCreate

A

This method called when a fragment instance initializes, just after the onAttach where fragment attaches to the host activity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

onCreateView() 

A

The method called when it’s time for the fragment to draw its user interface for the first time. To draw a UI for your fragment, you must return a View component from this method that is the root of your fragment’s layout. You can return null if the fragment does not provide a UI.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

onActivityCreated

A

This method called when Activity completes its onCreate() method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

onStart() 

A

This method called when a fragment is visible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

onResume()

A

This method called when a fragment is visible and allowing the user to interact with it. Fragment resumes only after activity resumes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

onPause

A

onPause() — This method called when a fragment is not allowing the user to interact; the fragment will get change with other fragment or it gets removed from activity or fragment’s activity called a pause.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

onStop

A

This method called when the fragment is no longer visible; the fragment will get change with other fragment or it gets removed from activity or fragment’s activity called stop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

onDestroyView

A

This method called when the view and related resources created in onCreateView() are removed from the activity’s view hierarchy and destroyed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

onDestroy

A

This method called when the fragment does its final clean up.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

onDetach

A

This method called when the fragment is detached from its host activity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly