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

Dive Into Android Fragments

Donn Felker
November 14, 2013

Dive Into Android Fragments

Slides from the "Dive into Android Fragments" class at AnDevCon

Donn Felker

November 14, 2013
Tweet

More Decks by Donn Felker

Other Decks in Programming

Transcript

  1. #andevcon Types of Fragments Fragment - Anything goes (for the

    most part) ListFragment - Lists. Yup. Thats it. Lists.
  2. #andevcon You decide which layout the Fragment should return. ListFragment

    automatically returns a new list view for you! ... but, if you’re using a ListFragment
  3. #andevcon Inversion of Control via Interface /** * Contract between

    caller and receiver for red buttons */ public interface RedButtonListener { void onRedButtonClick(); } @Override public void onRedButtonClick() { Toast.makeText(this, R.string.red_button_clicked, Toast.LENGTH_SHORT).show(); } in Activity redButtonListener.onRedButtonClick(); in Fragment RedButtonListener.java
  4. #andevcon Otto as an event bus . The activity is

    no longer the orchestrator. Activity ListFragment Waiver VehicleSelected manually Previous - Use Interface Now - No Interface Activity ListFragment Waiver Fragment fragments know of activity activity is simply a container Otto Otto moves messages to and from subscribers (observer pattern / event bus)