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

Fragments vs. CustomViews

Fragments vs. CustomViews

A quick talk showing the pros of use CustomViews instead Fragments to create our Android apps

Jorge Garrido

January 30, 2018
Tweet

More Decks by Jorge Garrido

Other Decks in Programming

Transcript

  1. #BADGlightningTalks 2018 Manual instantiation MyFragment fragment = MyFragment.newInstance(index); FragmentTransaction ft

    = getFragmentManager().beginTransaction(); ft.replace(R.id.parent, fragment); ft.commit(); MyCustomView customView = new MyCustomView(context); parentView.removeAllViews(); parentView.add(customView);
  2. #BADGlightningTalks 2018 Embedding in xml <fragment android:name="my.package.MyFragment" android:id="@+id/my_fragment" android:layout_width="match_parent" android:layout_height="match_parent"

    /> <my.package.MyCustomView android:id="@+id/my_view" android:layout_width="match_parent" android:layout_height="match_parent" />
  3. #BADGlightningTalks 2018 Create your own! Or use a router library

    like: Kartographer, Cicerone, Naviganto, Mortar, there are many!