Please enable JavaScript.
Coggle requires JavaScript to display documents.
FRAGMENTS (each fragment (lifetime (begins when it’s bound to its parent…
FRAGMENTS
each fragment
-
-
-
-
-
-
lifetime
begins when it’s bound to its parent Activity and ends when it’s been detached : (onAttach)<==:>(onDetach).
advantage
-
-
-
combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities.
-
-
-
Fragment VS Activity
-
-
The lifecycle of the Activity in which the Fragment lives directly affects the lifecycle of the Fragment.
-
Activities the UI is initialized within onCreate . Fragment's UI is initialized in onCreateViewand and then onDestroyView.
is
divide your Activities into fully encapsulated reusable components, each with its own lifecycle and UI.
Mini-activities, each with its own set of views
-
ADD Fragments
-
IN CODE
Dynamic
-
-
method
-
-
-
FragmentTransactions: Changes to the UI in terms of adding,
Removing and replacing Fragments
FragmentManager
-
2-create FragmentTransaction obj to begin the transaction of the previous manager using beginTransaction()
-
4- commit(); the transaction (This points to the Activity ViewGroupin which the fragment should be placed, specified by resource ID)
3- For remove(fragmentObject): need to know reference using findFragmentById or findFragmentByTag then pass the fragment instance to the remove
3- replace
-
2: Replace need to know container ID containing the Fragment to be replaced and the Fragment with which to replace and then add the transaction to the back stack (so can navigate back)
-
addToBackStack()
-
if you do call it Fragment is stopped and it is possible to resume it when the user navigates back..
-
ID vs Tag
ID
with acticity
you have added your Fragment to the Activity layout in XML, you can use the Fragment’s resource identifier
with transaction
should specify the resource identifier of the container View to which you added the Fragment you want to find
-
-
-
-
-
-
-