Dive Into Android Fragments

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →
Donn Felker
November 14, 2013

Dive Into Android Fragments

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

Donn Felker

November 14, 2013

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

47 slides
  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)

More Decks by Donn Felker

Other Decks in Programming