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

When to use Fragment s vs Activitie s?

Câu trả lời

Here is a concise answer to the question "When to use Fragments vs Activities in Android?":

Activities are the main building blocks of an Android app, representing a single screen with a user interface. They are responsible for managing the UI, handling user input, and orchestrating the app's lifecycle events[1][2][3]. Activities are typically used as the top-level components of an app's structure[2].

Fragments, on the other hand, are reusable pieces of UI that can be embedded within Activities. They have their own lifecycle, UI, and behavior[1][2][3]. Fragments are useful in the following scenarios:

  • When you want to create modular, reusable components for your UI[2]
  • When you need to adapt to different screen sizes and orientations[2]
  • To build dynamic and flexible interfaces, especially on tablets with larger screens[3]
  • To break down a complex UI into smaller, more manageable pieces[3]

In many cases, a combination of Activities and Fragments is the best approach[2]. Activities serve as the entry points to your app, while Fragments provide the building blocks for creating complex UIs within those Activities[2].

The key differences are:

  • Activ...
middle

middle

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

senior

What is the StrictMode ?

senior

What is Doze? What about App Standby?

junior

What is an Intent in Android?

Bình luận

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

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