Fragment me

of 16 /16
Alaa Alsalehi Serve Me

Embed Size (px)


Android lecture about fragment simple and easy talk

Transcript of Fragment me

  • 1. Alaa Alsalehi Serve Me

2. 3. What is fragment? Why fragment? How to use fragment? Lifecycle Advanced usages 4. A Fragment represents a behavior or a portion of user interface in an Activity. Reusable component. User interface Background worker 5. Why fragment? 6. Add to layout file 7. Add it dynamically to activity using fragment manager FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); ExampleFragment fragment = new ExampleFragment(); fragmentTransaction.add( er, fragment); fragmentTransaction.commit(); 8. Fragment represent sub-activity On attach and on detach like view. The other callback like activity. 9. Non UI Fragment Background worker Not a service Die when activity die Cache data Backup and restore when configuration change