Câu hỏi phỏng vấn Android
Câu hỏi

What is the difference between onCreate() and onCreateView() lifecycle methods in Fragment ?

Câu trả lời

The main difference between onCreate() and onCreateView() lifecycle methods in an Android Fragment is:

onCreate() is called to do initial fragment setup, such as creating views and non-UI related components. It is called after the fragment has been associated with its activity. Here you can initialize variables, create views, etc. but you cannot access the parent view hierarchy yet[1][3].

onCreateView() is called to have the fragment instantiate its user interface view. It is called after onCreate() and provides a View object that is the root of the fragment's layout. This is where you inflate the fragment's layout file. The inflated layout is returned as the View for the fragment[1][3][4].

In summary:

  • onCreate() is for initializing the fragment itself, while onCreateView() is for inflating the fragmen...
middle

middle

Gợi ý câu hỏi phỏng vấn

middle

What is the difference between ListView and RecyclerView ?

expert

What is Intent vs Sticky Intent vs Pending Intent ?

senior

What is the StrictMode ?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào