Fragment me
Embed Size (px)
description
Transcript of Fragment me
- 1. Alaa Alsalehi Serve Me
2. https://play.google.com/store/apps/developer?id=ServeMe 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(R.id.fragment_contain 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