Skip to content Skip to sidebar Skip to footer

Does Fragment Call The OnCreate Method Of Parent Activity?

I have an activity with a viewPager inside of it, and a static ArrayList of integers that I am shuffling using Collections.shuffle(list) in the activity's onCreate method, this vie

Solution 1:

Fragments are added to activity and therefore fragments get affected by activity. Activity can cause calling any fragment callback method, but fragment can't

The lifecycle of the activity in which the fragment lives directly affects the lifecycle of the fragment.

For example, when the activity receives onPause(), each fragment in the activity receives onPause().

Fragments have a few extra lifecycle callbacks, however, that handle unique interaction with the activity in order to perform actions such as build and destroy the fragment's UI. These additional callback methods are like onAttach(), onCreateView(), etc.

It'll clears the somewhat relation between fragment and activity.

Thanks


Post a Comment for "Does Fragment Call The OnCreate Method Of Parent Activity?"