Fragments Flashcards

1
Q

Describe a fragment

A

● A fragment represents a reusable portion of an app’s UI within an activity.
● A fragment defines and manages its own layout, has its own lifecycle, and can handle its own input events.

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

Can a fragment live on its own?

A

● Fragments cannot live on their own, rather, they must be hosted by an activity or another fragment.
● The fragment’s view hierarchy becomes part of, or attaches to, the host’s view hierarchy.

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

Describe modularity and how fragments ensure it

A

● Modularity is the extent to which a mobile application may be divided into smaller modules
● Fragments introduce modularity and reusability into your activity’s UI by allowing you
to divide the UI into discrete chunks.
● Fragments can be used to define and manage the UI of a single screen or portion of a screen.

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

Describe how fragments can be used to modify the app’s appearance at run time

A

● Dividing a UI into fragments makes it easier to modify an
activity’s appearance at runtime.
● While an activity is in the started lifecycle state or higher,
fragments can be added, replaced, or removed.

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

How can the changes made to an app’s appearance in during run time be reversed

A

One can keep a record of these changes in a back stack that is
managed by the activity, allowing the changes to be reversed.

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

Should there be dependencies between fragments?

A

● One can use multiple instances of the same fragment class within the same activity, multiple activities, or in child fragments.
● Therefore, fragments only need to have necessary logic for
independent UI management to avoid any dependencies among them.

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