title: Universal (tablet & phone) app - how best to structure - multiple layout xml or show/hide widgets?
body: <p>I'm planning my first real android app and I want it to be a universal app (tablet and phone).  The layout will be three list views that are populated by the previous list view (list one always has same list of items, list two will be populated based on the list one selection, list three will be populated based on list one &amp; two selections).  Once an item in list three is selected, the details will show about the item.  FYI, the data is in an XML file (containment hierarchy) and the details are the leaf nodes.</p>
  
  <p>I plan to have two layouts.  For the tablet, I'm going to have all three list view and the details on the same screen.  For the phone, I'm going to have each list occupy the entire screen and when an item in selected, slide transition to the next list view (with nav at the top for going to the previous list as well as info on what the selection(s) were from the previous lists).  When an item in the third list is selected, show the details page which will also have a button to start over (i.e. go back to the first list view).</p>
  
  <p>I've got the tablet view working pretty well since that's the simplest (just one screen, no transitions) - all in layout/main.xml.  I've also got different layouts for different size screens (layout, layout-large, layout-small, layout-xlarge) all of which have the exact same main.xml at the moment.</p>
  
  <p>So, finally to my question...  How do I use the same code to populate the lists while having different user experience?  I can see two options (please add more/better options)</p>
  
  <ol>
  <li><p>For the phone, should I continue to have one layout file (main.xml) and just have all three lists and the details on top of each other and via the slide transition, show/hide the widgets?  (i.e. at first only the first list view is visible, the second list view is hidden, the third list view is hidden, the details are hidden)</p></li>
  <li><p>Should I have one layout xml for each of the screens on the phone (main.xml - initial list view, list2.xml, list3.xml, and details.xml)?</p></li>
  </ol>
  
  <p>To determine if it's a tablet or not, I plan to use the code from the Google I/O app<br>
  <a href="https://stackoverflow.com/questions/6872190/developing-an-universal-android-application-phone-and-tablet">Developing an universal android application (phone and tablet)</a></p>
  
  <p><strong>EDIT</strong> (2011/11/29)<br>
  Found some good online resources regarding Fragments:<br>
  <a href="http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html" rel="nofollow noreferrer">http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html</a><br>
  <a href="http://portabledroid.wordpress.com/2011/06/22/25/" rel="nofollow noreferrer">http://portabledroid.wordpress.com/2011/06/22/25/</a><br>
  <a href="http://portabledroid.wordpress.com/2011/06/23/multi-platform-fragments-part-ii/" rel="nofollow noreferrer">http://portabledroid.wordpress.com/2011/06/23/multi-platform-fragments-part-ii/</a><br>
  and the accompanying video:<br>
  <a href="http://www.youtube.com/watch?v=4BKlST82Dtg" rel="nofollow noreferrer">http://www.youtube.com/watch?v=4BKlST82Dtg</a>  </p>