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

Fragments: What are they good for?

Fragments: What are they good for?

Fragments: What are they good for? Talk given at 360AnDev 2016 on July 28th, 2016
#360andev

David Hope

July 29, 2016
Tweet

Other Decks in Technology

Transcript

  1. Overview u Why Fragments? u Different types u Anatomy u

    Lifecycle u How to use u Common Usage u Best Practices
  2. onCreateView( ) Fixes u View – Hold Parameters u Inflater

    – Add Layout u View Container – Collection for Views u Bundle –Reconstructs Fragment
  3. newInstance( ) u Set up Fragment u Default Data u

    Bundle u SetArgs( ) u GetArgs( )
  4. Fragment Manager u Manages Fragments in Activity u Holds list

    of Fragments u Perform Transactions u Fluent Interface
  5. Identifying a Fragment u findFragmentById ( ) – Container ID

    u findFragmentByTag( ) – String Constant
  6. Pager Adapter u getCount( ) – Number of Fragments u

    getItem( ) – Position of Fragments u Fragment Pager Adapter u Fragment State Pager Adapter
  7. Best Practices u 3 – Fragments Activities u 5 –

    Fragments Tab Layouts u Use Interfaces with Activities u Create early