When I run any application where fragments are there which method will be called first?
Just like Activities has life cycle methods, similarly fragments also have their life cycle methods. When we load a fragment first method to be called is onAttach(), followed by onCreate(), which is followed by onCreateView(). Generally programmers will not implement onAttach() method. onCreate() is where we will initialize all the variables which are used in the fragment. onCreateView() is where we will inflate or load the xml file of our fragment and return it to the parent (activity).
Back To Top