Lines Matching full:fragment
55 android.app.Fragment} APIs. Fragments allow you to separate distinct behavioral components of your
82 <p>A {@link android.app.Fragment} represents a behavior or a portion of user interface in an
83 activity. You can think of a fragment as a modular section of an activity (a "fragment" of an
119 provide different fragment combinations for "tablets" and "handsets", it's still necessary that
130 3.0. Additionally, you can even implement the fragment design patterns and remain
182 one activity; on a handset, use separate activities to host each fragment. For example,
184 supply an alternative layout that includes just the first fragment. When running on a handset and
186 hosts the second fragment.</li>
191 and dynamically add each fragment as appropriate—rather than declare the fragments
192 in your activity's XML layout—because you <em>cannot</em> remove a fragment from an activity
195 are available for each fragment. In some cases, these factors might not affect your design, so
199 the fragment combinations in the activity's code (rather than use alternative layout resources to
200 define fragment combinations) and manage the back stack of fragments yourself (rather than
203 <p>This guide focuses on the second option, in which you display each fragment in a separate
205 files that define different fragment combinations for different screen sizes, keep fragment code
219 <li>On a tablet-sized screen, the Activity A layout contains both Fragment A and Fragment B.</li>
220 <li>On a handset-sized screen, the Activity A layout contains only Fragment A (the list
221 view). In order to show the details in Fragment B, Activity B must open.</li>
225 container to present Fragment B, so is only used on handset devices when the two fragments must
237 <!-- "Fragment A" -->
238 <fragment class="<b>com.example.android.TitlesFragment</b>"
254 <!-- "Fragment A" -->
255 <fragment class="<b>com.example.android.TitlesFragment</b>"
259 <!-- "Fragment B" -->
260 <fragment class="<b>com.example.android.DetailsFragment</b>"
288 Fragment B is available in the layout:</p>
290 <li>If Fragment B is in the layout, Activity A notifies Fragment B to update itself.</li>
291 <li>If Fragment B is <em>not</em> in the layout, Activity A starts Activity B (which hosts
292 Fragment B).</li>
301 <li>Do not manipulate one fragment directly from another.</li>
302 <li>Keep all code that concerns content in a fragment inside that fragment, rather than putting it
306 <p>To avoid directly calling one fragment from another, <strong>define a callback interface in each
307 fragment</strong> class that it can use to deliver events to
310 item), the activity responds appropriately based on the current fragment configuration.</p>
319 /** This is a callback that the list fragment (Fragment A)
325 // DisplayFragment (Fragment
332 // DisplayFragment (Fragment B) is in the layout (tablet layout),
333 // so tell the fragment to update
341 {@link android.content.Intent} and passes it to the <code>DisplayFragment</code> (Fragment B).</p>
343 <p>If Fragment B needs to deliver a result back to Fragment A (because Activity B was started with
345 works similarly with a callback interface between Fragment B and Activity B. That is, Activity B
346 implements a different callback interface defined by Fragment B. When Activity B receives the
347 callback with a result from the fragment, it sets the result for the activity (with {@link
349 result and delivers it to Fragment A.</p>
351 <p>For a demonstration of this technique for creating different fragment combinations for
469 handset and your application shows just one fragment at a time, it might be appropriate to enable up
471 fragment in a multi-pane configuration.</p>