1page.title=Building a Dynamic UI with Fragments 2page.tags=fragments,user interface,support library 3helpoutsWidget=true 4 5trainingnavtop=true 6startpage=true 7 8@jd:body 9 10<div id="tb-wrapper"> 11<div id="tb"> 12 13 14<h2>Dependencies and prerequisites</h2> 15<ul> 16 <li>Basic knowledge of the Activity lifecycle (see <a 17href="{@docRoot}training/basics/activity-lifecycle/index.html">Managing the Activity 18Lifecycle</a>)</li> 19 <li>Experience building <a href="{@docRoot}guide/topics/ui/declaring-layout.html">XML 20layouts</a></li> 21</ul> 22 23 24<h2>You should also read</h2> 25<ul> 26 <li><a href="{@docRoot}guide/components/fragments.html">Fragments</a></li> 27 <li><a href="{@docRoot}guide/practices/tablets-and-handsets.html">Supporting Tablets and 28Handsets</a></li> 29</ul> 30 31 32<h2>Try it out</h2> 33 34<div class="download-box"> 35 <a href="http://developer.android.com/shareables/training/FragmentBasics.zip" 36class="button">Download the sample</a> 37 <p class="filename">FragmentBasics.zip</p> 38</div> 39 40</div> 41</div> 42 43<p>To create a dynamic and multi-pane user interface on Android, you need to encapsulate 44UI components and activity behaviors into modules that you can swap into and out of 45your activities. You can create these modules with the {@link android.app.Fragment} class, which 46behaves somewhat like a nested activity that can define its own layout and manage its own 47lifecycle.</p> 48 49<p>When a fragment specifies its own layout, it can be configured in different combinations with 50other fragments inside an activity to modify your layout configuration for different screen 51sizes (a small screen might show one fragment at a time, but a large screen can show two or 52more).</p> 53 54<p>This class shows you how to create a dynamic user experience with fragments and optimize your 55app's user experience for devices with different screen sizes, all while continuing to support 56devices running versions as old as Android 1.6.</p> 57 58<h2>Lessons</h2> 59 60<dl> 61 <dt><b><a href="creating.html">Creating a Fragment</a></b></dt> 62 <dd>Learn how to build a fragment and implement basic behaviors within its callback 63methods.</dd> 64 <dt><b><a href="fragment-ui.html">Building a Flexible UI</a></b></dt> 65 <dd>Learn how to build your app with layouts that provide different fragment configurations for 66different screens.</dd> 67 <dt><b><a href="communicating.html">Communicating with Other Fragments</a></b></dt> 68 <dd>Learn how to set up communication paths from a fragment to the activity and other 69fragments.</dd> 70</dl> 71 72