SlideShare a Scribd company logo
Fragments
Alex Gherghisan & Vlad Harbuz
Problema 1
Varietatea mare de dispozitive necesita un UI
 flexibil si usor de adaptat.

Exemplu:
Problema 2
UI-ul presupune schimbarea rapida intre pagini
  ale layout-ului.

Exemplu: Moneytracker!
Solutie
Layout modular
Stiu ce va ganditi...
Stiu ce va ganditi...


"Ce sexy! Dar cum fac asta?"
Ce e un Fragment?
- un fel de sub-Activity
- refolosibil in mai multe Activity-uri
- are propriul lifecycle




Mentiune:
- un Fragment nu trebuie neaparat sa aiba interfata
Cum il folosim?
Facem cateva subclase din Fragment.
Pentru tableta
Bagam aceste Fragment-uri in res/layout-land/
 (pentru landscape).
Pentru telefon
In res/layout/, punem layoutul simplificat pentru
  telefon.
Modificarea Fragment-urilor
Cum ramane cu problema 2?
"UI-ul presupune schimbarea rapida intre pagini
  ale layout-ului."
ViewPager
Un ViewPager ii permite utilizatorului sa
 navigheze prin pagini ale layoutului folosind
 swipe-uri.

ViewPager-ul este definit in layout si Fragment-
  urile se incarca in el programatic, prin
  adapter.
Tipuri de adaptere pentru
ViewPager
FragmentPagerAdapter
Poate fi folosit atunci cand avem un numar
  limitat de Fragment-uri, toate fiind tinute in
  memorie.

FragmentStatePagerAdapter
Tine in memorie doar Fragment-urile vizibile si
  pe restul le creeza cand are nevoie de ele.
Fragments in Android
Multumim! :D
Big Black Cock
Resurse:
•   Fragments | Android Developers
•   ViewPager | Android Developers

More Related Content

PDF
Android Alarms & Broadcast Receivers
PDF
Themes and Styles in Android
PPTX
Programatica Mobile - editia 2012
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
PDF
2024 State of Marketing Report – by Hubspot
Android Alarms & Broadcast Receivers
Themes and Styles in Android
Programatica Mobile - editia 2012
2024 Trend Updates: What Really Works In SEO & Content Marketing
Storytelling For The Web: Integrate Storytelling in your Design Process
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
2024 State of Marketing Report – by Hubspot
Ad

Fragments in Android