Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's up, droid - Fragments

What's up, droid - Fragments

Short speech for the Mobile Computing class at Fontys Hogescholen, about Fragments in Android Applications.

João Otávio Ferreira Barbosa

December 17, 2014
Tweet

More Decks by João Otávio Ferreira Barbosa

Other Decks in Programming

Transcript

  1. Fragments ◦ Represent a behavior or a portion of user

    interface inside the UI. ◦ (Almost) independent. ◦ Reusable for different contents.
  2. Fragments ◦ Minimal set up: □ An Activity; □ Class

    which extends Fragment; □ Override, at least, the onCreateView method;
  3. Add to an activity ◦ There are two ways to

    add an fragment to an activity: □ Declare it inside the activity's layout file □ Add the fragment programatically to a ViewGroup * * for example: FrameLayout, LinearLayout...
  4. The Fragment Manager & Transactions ◦ Classes to work with

    Fragments. ◦ Allows to add(), remove() or replace() fragments. ◦ Remember to always commit().