Fragment Lifecycle Flashcards

1
Q

onAttach

A

The first stage of Fragment initialization.

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

onCreate

A

The system calls this when creating the fragment. Within your implementation, you should initialize essential components of the fragment that you want to retain when the fragment is paused or stopped, then resumed.

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

onCreateView

A

The system calls this 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 from this method that is the root of your fragment’s layout. You can return null if the fragment does not provide a UI.

When the Activity that the Fragment has been included in returns from the Activity stack, the logic here is run as part of the resuming process.

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

onActivityCreated

A

The Activity the Fragment is in has been fully created or resumed.

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

onStart

A

Called when the Fragment has been started.

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

onResume

A

This will run when the Fragment resumes, and is the last point for logic changed before the Fragment is considered active.

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

onPause

A

As the Fragment is placed into the back stack, the logic here is processed.

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

onStop

A

The Fragment is going to be destroyed soon, so the logic can be run here.

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

onDestroyView

A

The current view is going to either load the Fragment back to the Activity cycle through onCreateView() or be destroyed.

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

onDestroy

A

The Fragment is going to be destroyed; this is the last chance for the logic to be run before the Fragment is destroyed and detached from the view.

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

onDetach

A

As the Fragment is removed, this is the last method you can work with as part of the Fragment-destroy process.

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