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