Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1

Adding Layout Flexibility


Adding Layout Flexibility


On a phone, you want CrimeListActivity to inflate a single-pane layout, as it currently does. On a
tablet, you want it to inflate a two-pane layout that is capable of displaying the master and detail views
at the same time.


In the two-pane layout, CrimeListActivity will host both a CrimeListFragment and a
CrimeFragment, as shown in Figure 17.3.


Figure 17.3  Different types of layouts


To make this happen, you are going to:



  • modify SingleFragmentActivity so that the layout that gets inflated is not hardcoded

  • create a new layout that consists of two fragment containers

  • modify CrimeListActivity so that it will inflate a single-container layout on phones and a two-
    container layout on tablets

Free download pdf