Home | History | Annotate | Download | only in components
      1 page.title=
      2 parent.title=Activity
      3 parent.link=activities.html
      4 @jd:body
      5 
      6 <div id="qv-wrapper">
      7 <div id="qv">
      8   <h2></h2>
      9   <ol>
     10     <li><a href="#Design"></a></li>
     11     <li><a href="#Creating">
     12       <ol>
     13         <li><a href="#UI"></a></li>
     14         <li><a href="#Adding"> Activity </a></li>
     15       </ol>
     16     </li>
     17     <li><a href="#Managing"></a></li>
     18     <li><a href="#Transactions"></a></li>
     19     <li><a href="#CommunicatingWithActivity"> Activity </a>
     20       <ol>
     21         <li><a href="#EventCallbacks"> Activity </a></li>
     22         <li><a href="#ActionBar"></a></li>
     23       </ol>
     24     </li>
     25     <li><a href="#Lifecycle"></a>
     26       <ol>
     27         <li><a href="#CoordinatingWithActivity"> Activity </a></li>
     28       </ol>
     29     </li>
     30     <li><a href="#Example"></a></li>
     31   </ol>
     32 
     33   <h2></h2>
     34   <ol>
     35     <li>{@link android.app.Fragment}</li>
     36     <li>{@link android.app.FragmentManager}</li>
     37     <li>{@link android.app.FragmentTransaction}</li>
     38   </ol>
     39   
     40   <h2></h2>
     41   <ol>
     42     <li><a href="{@docRoot}training/basics/fragments/index.html"> UI</a></li>
     43     <li><a href="{@docRoot}guide/practices/tablets-and-handsets.html"></a>
     44 </li>
     45   </ol>
     46 </div>
     47 </div>
     48 
     49 <p>{@link android.app.Fragment} 
     50 {@link android.app.Activity}  Activity 
     51 UI Activity  Activity  Activity  Activity  Activity
     52 
     53 
     54 </p>
     55 
     56 <p> Activity  Activity 
     57  Activity  Activity 
     58  Activity <em></em><a href="{@docRoot}guide/components/activities.html#Lifecycle"></a>
     59 
     60  Activity &mdash;Activity 
     61 
     62 
     63 <em></em>
     64 </p>
     65 
     66 <p> Activity  Activity  {@link
     67 android.view.ViewGroup}
     68  Activity 
     69 {@code &lt;fragment&gt;}
     70  Activity 
     71 {@link android.view.ViewGroup} Activity 
     72 UI
     73  Activity </p>
     74 
     75 <p> Activity  Activity  Activity  Activity 
     76 
     77 
     78 </p>
     79 
     80 
     81 <h2 id="Design"></h2>
     82 
     83 <p>Android  Android 3.0API 11  UI
     84 
     85 UI
     86 
     87  Activity  Activity  Activity 
     88 
     89 </p>
     90 
     91 <p>&mdash; Activity 
     92 
     93 
     94  Activity  Activity  Activity 
     95 1
     96 </p>
     97 
     98 <p> Activity  Activity
     99 
    100 
    101 
    102 
    103 
    104  Activity 
    105 UI
    106 </p>
    107 
    108 <img src="{@docRoot}images/fundamentals/fragments.png" alt="" />
    109 <p class="img-caption"><strong> 1. </strong>
    110 UI
    111  Activity </p>
    112 
    113 <p>&mdash;&mdash;<em>Activity
    114 A</em> <em>Activity
    115 A</em>
    116 <em>Activity
    117 B</em>
    118 1
    119 </p>
    120 
    121 <p><a href="{@docRoot}guide/practices/tablets-and-handsets.html"></a>
    122 </p>
    123 
    124 
    125 
    126 <h2 id="Creating"></h2>
    127 
    128 <div class="figure" style="width:327px">
    129 <img src="{@docRoot}images/fragment_lifecycle.png" alt="" />
    130 <p class="img-caption"><strong> 2. </strong> Activity 
    131 </p>
    132 </div>
    133 
    134 <p> {@link android.app.Fragment}
    135 {@link android.app.Fragment} 
    136 {@link android.app.Activity}  Activity 
    137 {@link android.app.Fragment#onCreate onCreate()}{@link android.app.Fragment#onStart onStart()}{@link android.app.Fragment#onPause onPause()}
    138  {@link android.app.Fragment#onStop onStop()}
    139 Android
    140  Activity 
    141 </p>
    142 
    143 <p></p>
    144 
    145 <dl>
    146   <dt>{@link android.app.Fragment#onCreate onCreate()}</dt>
    147   <dd>
    148 
    149 </dd>
    150   <dt>{@link android.app.Fragment#onCreateView onCreateView()}</dt>
    151   <dd>
    152 
    153 UI {@link android.view.View} 
    154 UI null</dd>
    155   <dt>{@link android.app.Activity#onPause onPause()}</dt>
    156   <dd>
    157 
    158 
    159 </dd>
    160 </dl>
    161 
    162 <p>
    163 
    164 <a href="#Lifecycle"></a>
    165 </p>
    166 
    167 
    168 <p> {@link
    169 android.app.Fragment} </p>
    170 
    171 <dl>
    172   <dt>{@link android.app.DialogFragment}</dt>
    173   <dd>
    174 {@link android.app.Activity}
    175  Activity 
    176 </dd>
    177 
    178   <dt>{@link android.app.ListFragment}</dt>
    179   <dd> {@link
    180 android.widget.SimpleCursorAdapter} {@link android.app.ListActivity}
    181 {@link
    182 android.app.ListFragment#onListItemClick(ListView,View,int,long) onListItemClick()}
    183 </dd>
    184 
    185   <dt>{@link android.preference.PreferenceFragment}</dt>
    186   <dd> {@link android.preference.Preference} 
    187 {@link android.preference.PreferenceActivity} Activity 
    188 </dd>
    189 </dl>
    190 
    191 
    192 <h3 id="UI"></h3>
    193 
    194 <p> Activity  Activity
    195 </p>
    196 
    197 <p> {@link
    198 android.app.Fragment#onCreateView onCreateView()} Android
    199 
    200 {@link android.view.View} </p>
    201 
    202 <p class="note"><strong></strong> {@link
    203 android.app.ListFragment} 
    204 {@link android.app.Fragment#onCreateView onCreateView()}  {@link android.widget.ListView}</p>
    205 
    206 <p> {@link
    207 android.app.Fragment#onCreateView onCreateView()}  XML <a href="{@docRoot}guide/topics/resources/layout-resource.html"></a>{@link android.app.Fragment#onCreateView onCreateView()}
    208 
    209 {@link android.view.LayoutInflater} </p>
    210 
    211 <p> {@link android.app.Fragment}  {@code example_fragment.xml}
    212 </p>
    213 
    214 <pre>
    215 public static class ExampleFragment extends Fragment {
    216     &#64;Override
    217     public View onCreateView(LayoutInflater inflater, ViewGroup container,
    218                              Bundle savedInstanceState) {
    219         // Inflate the layout for this fragment
    220         return inflater.inflate(R.layout.example_fragment, container, false);
    221     }
    222 }
    223 </pre>
    224 
    225 <div class="sidebox-wrapper">
    226 <div class="sidebox">
    227   <h3></h3>
    228   <p>{@code R.layout.example_fragment} 
    229 {@code example_fragment.xml} 
    230 XML
    231 <a href="{@docRoot}guide/topics/ui/index.html"></a></p>
    232 </div>
    233 </div>
    234 
    235 <p> {@link android.app.Fragment#onCreateView
    236 onCreateView()}  {@code container}
    237 
    238 {@link android.view.ViewGroup} Activity {@code savedInstanceState}
    239 
    240 {@link android.os.Bundle}<a href="#Lifecycle"></a>
    241 </p>
    242 
    243 <p>{@link android.view.LayoutInflater#inflate(int,ViewGroup,boolean) inflate()}
    244 </p>
    245 <ul>
    246   <li> ID</li>
    247   <li> {@link android.view.ViewGroup} {@code
    248 container}
    249 </li>
    250   <li> {@link
    251 android.view.ViewGroup}
    252 false {@code
    253 container}&mdash; true </li>
    254 </ul>
    255 
    256 <p> Activity 
    257 </p>
    258 
    259 
    260 
    261 <h3 id="Adding"> Activity </h3>
    262 
    263 <p> Activity 
    264 UI Activity  Activity  Activity 
    265 </p>
    266 
    267 <ul>
    268   <li><b> Activity </b>
    269 <p>
    270  Activity 
    271 </p>
    272 <pre>
    273 &lt;?xml version="1.0" encoding="utf-8"?&gt;
    274 &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    275     android:orientation="horizontal"
    276     android:layout_width="match_parent"
    277     android:layout_height="match_parent"&gt;
    278     &lt;fragment android:name="com.example.news.ArticleListFragment"
    279             android:id="@+id/list"
    280             android:layout_weight="1"
    281             android:layout_width="0dp"
    282             android:layout_height="match_parent" /&gt;
    283     &lt;fragment android:name="com.example.news.ArticleReaderFragment"
    284             android:id="@+id/viewer"
    285             android:layout_weight="2"
    286             android:layout_width="0dp"
    287             android:layout_height="match_parent" /&gt;
    288 &lt;/LinearLayout&gt;
    289 </pre>
    290   <p>{@code &lt;fragment&gt;}  {@code android:name}  {@link
    291 android.app.Fragment} </p>
    292 
    293 <p> Activity 
    294 {@link android.app.Fragment#onCreateView onCreateView()}
    295  {@link android.view.View} 
    296 {@code &lt;fragment&gt;} </p>
    297 
    298 <div class="note">
    299   <p><strong></strong> Activity 
    300 
    301 
    302 ID</p>
    303   <ul>
    304     <li> {@code android:id}  ID</li>
    305     <li> {@code android:tag} </li>
    306     <li> ID
    307 </li>
    308   </ul>
    309 </div>
    310   </li>
    311 
    312   <li><b> {@link android.view.ViewGroup}</b>
    313 <p> Activity  Activity 
    314 {@link
    315 android.view.ViewGroup}</p>
    316   <p> Activity 
    317 {@link android.app.FragmentTransaction}  API
    318 {@link android.app.Activity}  {@link android.app.FragmentTransaction} </p>
    319 
    320 <pre>
    321 FragmentManager fragmentManager = {@link android.app.Activity#getFragmentManager()}
    322 FragmentTransaction fragmentTransaction = fragmentManager.{@link android.app.FragmentManager#beginTransaction()};
    323 </pre>
    324 
    325 <p> {@link
    326 android.app.FragmentTransaction#add(int,Fragment) add()}
    327 </p>
    328 
    329 <pre>
    330 ExampleFragment fragment = new ExampleFragment();
    331 fragmentTransaction.add(R.id.fragment_container, fragment);
    332 fragmentTransaction.commit();
    333 </pre>
    334 
    335   <p> {@link android.app.FragmentTransaction#add(int,Fragment) add()}
    336  {@link android.view.ViewGroup}
    337 ID </p>
    338   <p>
    339 {@link android.app.FragmentTransaction} 
    340 {@link android.app.FragmentTransaction#commit} </p>
    341   </li>
    342 </ul>
    343 
    344 
    345 <h4 id="AddingWithoutUI"> UI </h4>
    346 
    347 <p> Activity 
    348 UI Activity 
    349 UI</p>
    350 
    351 <p> UI  {@link
    352 android.app.FragmentTransaction#add(Fragment,String)}  Activity 
    353 ID Activity 
    354 {@link
    355 android.app.Fragment#onCreateView onCreateView()} </p>
    356 
    357 <p> UI &mdash; UI
    358 &mdash;
    359 UI Activity 
    360 {@link android.app.FragmentManager#findFragmentByTag
    361 findFragmentByTag()}</p>
    362 
    363 <p> UI  Activity {@code
    364 FragmentRetainInstance.java}  SDK 
    365 Android SDK  
    366 <code>&lt;sdk_root&gt;/APIDemos/app/src/main/java/com/example/android/apis/app/FragmentRetainInstance.java</code> </p>
    367 
    368 
    369 
    370 <h2 id="Managing"></h2>
    371 
    372 <p> Activity  {@link android.app.FragmentManager} Activity 
    373 {@link android.app.Activity#getFragmentManager()}</p>
    374 
    375 <p> {@link android.app.FragmentManager} </p>
    376 
    377 <ul>
    378   <li> {@link
    379 android.app.FragmentManager#findFragmentById findFragmentById()} Activity  UI
    380  {@link android.app.FragmentManager#findFragmentByTag
    381 findFragmentByTag()} UI  Activity </li> 
    382   <li> {@link
    383 android.app.FragmentManager#popBackStack()} <em>Back</em> </li>
    384   <li> {@link
    385 android.app.FragmentManager#addOnBackStackChangedListener addOnBackStackChangedListener()} </li>
    386 </ul>
    387 
    388 <p> {@link
    389 android.app.FragmentManager} </p>
    390 
    391 <p> {@link android.app.FragmentManager}
    392 
    393 {@link android.app.FragmentTransaction}</p>
    394 
    395 
    396 <h2 id="Transactions"></h2>
    397 
    398 <p> Activity 
    399  Activity 
    400 {@link
    401 android.app.FragmentTransaction}  API  Activity  Activity
    402 
    403 </p>
    404 
    405 <p> {@link
    406 android.app.FragmentManager}  {@link android.app.FragmentTransaction} </p>
    407 
    408 <pre>
    409 FragmentManager fragmentManager = {@link android.app.Activity#getFragmentManager()};
    410 FragmentTransaction fragmentTransaction = fragmentManager.{@link android.app.FragmentManager#beginTransaction()};
    411 </pre>
    412 
    413 <p>
    414 {@link
    415 android.app.FragmentTransaction#add add()}{@link android.app.FragmentTransaction#remove remove()}  {@link android.app.FragmentTransaction#replace replace()}
    416  Activity
    417 {@link android.app.FragmentTransaction#commit()}</p>
    418 </dl>
    419 
    420 <p> {@link
    421 android.app.FragmentTransaction#commit()}  {@link
    422 android.app.FragmentTransaction#addToBackStack addToBackStack()}
    423  Activity 
    424 <em></em> </p>
    425 
    426 <p>
    427 </p>
    428 
    429 <pre>
    430 // Create new fragment and transaction
    431 Fragment newFragment = new ExampleFragment();
    432 FragmentTransaction transaction = getFragmentManager().beginTransaction();
    433 
    434 // Replace whatever is in the fragment_container view with this fragment,
    435 // and add the transaction to the back stack
    436 transaction.replace(R.id.fragment_container, newFragment);
    437 transaction.addToBackStack(null);
    438 
    439 // Commit the transaction
    440 transaction.commit();
    441 </pre>
    442 
    443 <p>{@code newFragment}
    444  {@code R.id.fragment_container} ID  {@link
    445 android.app.FragmentTransaction#addToBackStack addToBackStack()}
    446 
    447 <em></em></p>
    448 
    449 <p> {@link
    450 android.app.FragmentTransaction#add add()}  {@link android.app.FragmentTransaction#remove
    451 remove()} {@link
    452 android.app.FragmentTransaction#addToBackStack addToBackStack()}
    453 {@link android.app.FragmentTransaction#commit commit()} 
    454 <em></em></p>
    455 
    456 <p> {@link android.app.FragmentTransaction}
    457 </p>
    458 <ul>
    459   <li> {@link android.app.FragmentTransaction#commit()}</li>
    460   <li>
    461 </li>
    462 </ul>
    463 
    464 <p> {@link android.app.FragmentTransaction#addToBackStack(String)
    465 addToBackStack()}
    466 
    467 {@link android.app.FragmentTransaction#addToBackStack(String) addToBackStack()}<em></em>
    468 
    469 </p>
    470 
    471 <p class="note"><strong></strong>
    472 {@link android.app.FragmentTransaction#setTransition setTransition()}
    473 </p>
    474 
    475 <p> {@link android.app.FragmentTransaction#commit()}
    476  Activity  UI
    477  UI  {@link
    478 android.app.FragmentManager#executePendingTransactions()} 
    479 {@link android.app.FragmentTransaction#commit()} 
    480 </p>
    481 
    482 <p class="caution"><strong></strong> Activity<a href="{@docRoot}guide/components/activities.html#SavingActivityState"></a> Activity {@link
    483 android.app.FragmentTransaction#commit commit()}
    484 
    485  Activity
    486  {@link
    487 android.app.FragmentTransaction#commitAllowingStateLoss()}</p>
    488 
    489 
    490 
    491 
    492 <h2 id="CommunicatingWithActivity"> Activity </h2>
    493 
    494 <p> {@link android.app.Fragment} 
    495 {@link android.app.Activity}
    496  Activity  Activity</p>
    497 
    498 <p> {@link
    499 android.app.Fragment#getActivity()}
    500  {@link android.app.Activity}  Activity </p>
    501 
    502 <pre>
    503 View listView = {@link android.app.Fragment#getActivity()}.{@link android.app.Activity#findViewById findViewById}(R.id.list);
    504 </pre>
    505 
    506 <p> Activity 
    507 {@link
    508 android.app.FragmentManager#findFragmentById findFragmentById()}  {@link
    509 android.app.FragmentManager#findFragmentByTag findFragmentByTag()} {@link android.app.FragmentManager}  {@link android.app.Fragment} </p>
    510 
    511 <pre>
    512 ExampleFragment fragment = (ExampleFragment) getFragmentManager().findFragmentById(R.id.example_fragment);
    513 </pre>
    514 
    515 
    516 <h3 id="EventCallbacks"> Activity </h3>
    517 
    518 <p> Activity  Activity 
    519 
    520  Activity 
    521 </p>
    522 
    523 <p> Activity  &mdash; A B&mdash; A Activity B 
    524 
    525 {@code OnArticleSelectedListener}
    526  A </p>
    527 
    528 <pre>
    529 public static class FragmentA extends ListFragment {
    530     ...
    531     // Container Activity must implement this interface
    532     public interface OnArticleSelectedListener {
    533         public void onArticleSelected(Uri articleUri);
    534     }
    535     ...
    536 }
    537 </pre>
    538 
    539 <p> Activity 
    540 {@code OnArticleSelectedListener}
    541  {@code onArticleSelected()} A
    542  B Activity  A  {@link
    543 android.app.Fragment#onAttach onAttach()}
    544  Activity 
    545 {@link android.app.Fragment#onAttach
    546 onAttach()}  {@link android.app.Activity}  {@code OnArticleSelectedListener} </p>
    547 
    548 <pre>
    549 public static class FragmentA extends ListFragment {
    550     OnArticleSelectedListener mListener;
    551     ...
    552     &#64;Override
    553     public void onAttach(Activity activity) {
    554         super.onAttach(activity);
    555         try {
    556             mListener = (OnArticleSelectedListener) activity;
    557         } catch (ClassCastException e) {
    558             throw new ClassCastException(activity.toString() + " must implement OnArticleSelectedListener");
    559         }
    560     }
    561     ...
    562 }
    563 </pre>
    564 
    565 <p> Activity 
    566 {@link java.lang.ClassCastException}{@code mListener}
    567  Activity  {@code OnArticleSelectedListener}  A 
    568 {@code OnArticleSelectedListener}
    569  Activity  A 
    570 {@link android.app.ListFragment}
    571  {@link android.app.ListFragment#onListItemClick
    572 onListItemClick()} {@code onArticleSelected()}
    573  Activity </p>
    574 
    575 <pre>
    576 public static class FragmentA extends ListFragment {
    577     OnArticleSelectedListener mListener;
    578     ...
    579     &#64;Override
    580     public void onListItemClick(ListView l, View v, int position, long id) {
    581         // Append the clicked item's row ID with the content provider Uri
    582         Uri noteUri = ContentUris.{@link android.content.ContentUris#withAppendedId withAppendedId}(ArticleColumns.CONTENT_URI, id);
    583         // Send the event and Uri to the host activity
    584         mListener.onArticleSelected(noteUri);
    585     }
    586     ...
    587 }
    588 </pre>
    589 
    590 <p> {@link
    591 android.app.ListFragment#onListItemClick onListItemClick()}  {@code id} 
    592 ID Activity {@link
    593 android.content.ContentProvider}  ID</p>
    594 
    595 <p><!--To see a complete implementation of this kind of callback interface, see the <a
    596 href="{@docRoot}resources/samples/NotePad/index.html">NotePad sample</a>. --><a href="{@docRoot}guide/topics/providers/content-providers.html"></a>
    597 </p>
    598 
    599 
    600 
    601 <h3 id="ActionBar"></h3>
    602 
    603 <p>
    604 {@link android.app.Fragment#onCreateOptionsMenu(Menu,MenuInflater) onCreateOptionsMenu()}  Activity <a href="{@docRoot}guide/topics/ui/menus.html#options-menu"></a><a href="{@docRoot}guide/topics/ui/actionbar.html"></a>
    605 {@link
    606 android.app.Fragment#onCreate(Bundle) onCreate()}  {@link
    607 android.app.Fragment#setHasOptionsMenu(boolean) setHasOptionsMenu()}
    608 {@link android.app.Fragment#onCreateOptionsMenu onCreateOptionsMenu()}
    609 </p>
    610 
    611 <p>
    612  {@link
    613 android.app.Fragment#onOptionsItemSelected(MenuItem) onOptionsItemSelected()}
    614 </p>
    615 
    616 <p> {@link
    617 android.app.Fragment#registerForContextMenu(View) registerForContextMenu()}
    618 {@link
    619 android.app.Fragment#onCreateContextMenu(ContextMenu,View,ContextMenu.ContextMenuInfo)
    620 onCreateContextMenu()}  {@link
    621 android.app.Fragment#onContextItemSelected(MenuItem) onContextItemSelected()} </p>
    622 
    623 <p class="note"><strong></strong>Activity 
    624 
    625  Activity 
    626 
    627 </p>
    628 
    629 <p><a href="{@docRoot}guide/topics/ui/menus.html"></a><a href="{@docRoot}guide/topics/ui/actionbar.html"></a></p>
    630 
    631 
    632 
    633 
    634 <h2 id="Lifecycle"></h2>
    635 
    636 <div class="figure" style="width:350px">
    637 <img src="{@docRoot}images/activity_fragment_lifecycle.png" alt="" />
    638 <p class="img-caption"><strong> 3. </strong>Activity 
    639 </p>
    640 </div>
    641 
    642 <p> Activity  Activity 
    643 </p>
    644 
    645 <dl>
    646   <dt><i></i></dt>
    647     <dd> Activity </dd>
    648 
    649   <dt><i></i></dt>
    650     <dd> Activity  Activity  Activity 
    651 
    652 </dd>
    653 
    654   <dt><i></i></dt>
    655     <dd> Activity  Activity 
    656 
    657  Activity 
    658 </dd>
    659 </dl>
    660 
    661 <p> Activity  Activity  Activity  {@link
    662 android.os.Bundle}
    663  {@link
    664 android.app.Fragment#onSaveInstanceState onSaveInstanceState()} 
    665 {@link android.app.Fragment#onCreate onCreate()}{@link
    666 android.app.Fragment#onCreateView onCreateView()}  {@link
    667 android.app.Fragment#onActivityCreated onActivityCreated()} <a href="{@docRoot}guide/components/activities.html#SavingActivityState">Activity</a>
    668 
    669 </p>
    670 
    671 <p>Activity 
    672 Activity  Activity 
    673 <em></em>
    674 Activity<a href="{@docRoot}guide/components/tasks-and-back-stack.html"></a>
    675 {@link
    676 android.app.FragmentTransaction#addToBackStack(String) addToBackStack()}
    677  Activity 
    678 </p>
    679 
    680 <p> Activity 
    681 <a href="{@docRoot}guide/components/activities.html#Lifecycle"> Activity </a>
    682  Activity 
    683 </p>
    684 
    685 <p class="caution"><strong></strong> {@link android.app.Fragment}
    686  {@link android.content.Context}
    687  {@link android.app.Fragment#getActivity()} Activity 
    688 {@link android.app.Fragment#getActivity()}
    689 {@link android.app.Fragment#getActivity()}  null</p>
    690 
    691 
    692 <h3 id="CoordinatingWithActivity"> Activity </h3>
    693 
    694 <p> Activity Activity 
    695 
    696  Activity  {@link android.app.Activity#onPause} Activity 
    697 {@link android.app.Fragment#onPause}</p>
    698 
    699 <p> Activity  UI 
    700 
    701 </p>
    702 
    703 <dl>
    704   <dt>{@link android.app.Fragment#onAttach onAttach()}</dt>
    705     <dd> Activity {@link
    706 android.app.Activity} </dd>
    707   <dt>{@link android.app.Fragment#onCreateView onCreateView()}</dt>
    708     <dd></dd>
    709   <dt>{@link android.app.Fragment#onActivityCreated onActivityCreated()}</dt>
    710     <dd> Activity  {@link android.app.Activity#onCreate
    711 onCreate()} </dd>
    712   <dt>{@link android.app.Fragment#onDestroyView onDestroyView()}</dt>
    713     <dd></dd>
    714   <dt>{@link android.app.Fragment#onDetach onDetach()}</dt>
    715     <dd> Activity </dd>
    716 </dl>
    717 
    718 <p> 3
    719  Activity  Activity 
    720  Activity  {@link
    721 android.app.Activity#onCreate onCreate()} Activity 
    722 {@link android.app.Fragment#onActivityCreated onActivityCreated()} </p>
    723 
    724 <p> Activity  Activity 
    725  Activity 
    726 </p>
    727 
    728 <p> Activity  Activity 
    729 </p>
    730 
    731 
    732 
    733 
    734 <h2 id="Example"></h2>
    735 
    736 <p> Activity 
    737  Activity 
    738 
    739 
    740 </p>
    741 
    742 <p class="note"><strong></strong><a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.html">{@code
    743 FragmentLayout.java}</a>
    744  Activity </p>
    745 
    746 <p> Activity  {@link
    747 android.app.Activity#onCreate onCreate()} </p>
    748 
    749 {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java main}
    750 
    751 <p> {@code fragment_layout.xml}</p>
    752 
    753 {@sample development/samples/ApiDemos/res/layout-land/fragment_layout.xml layout}
    754 
    755 <p> Activity 
    756 {@code TitlesFragment}
    757 {@link android.widget.FrameLayout}
    758 
    759 {@link android.widget.FrameLayout}</p>
    760 
    761 <p>
    762 
    763 {@code res/layout-land/fragment_layout.xml}</p>
    764 
    765 <p>
    766 {@code res/layout/fragment_layout.xml}</p>
    767 
    768 {@sample development/samples/ApiDemos/res/layout/fragment_layout.xml layout}
    769 
    770 <p> {@code TitlesFragment}
    771  Activity 
    772 
    773 </p>
    774 
    775 <p> {@code
    776 TitlesFragment} {@link
    777 android.app.ListFragment}</p>
    778 
    779 <p>
    780 {@link
    781 android.widget.FrameLayout}
    782 </p>
    783 
    784 {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java titles}
    785 
    786 <p> {@code DetailsFragment} 
    787 {@code TitlesFragment} </p>
    788  
    789 {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java details}
    790 
    791 <p> {@code TitlesFragment} <em></em> {@code R.id.details}
    792 
    793 {@code DetailsFragment}  {@code DetailsActivity}
    794 Activity </p>
    795 
    796 <p> {@code DetailsActivity}
    797 {@code DetailsFragment}</p>
    798 
    799 {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.java
    800 details_activity}
    801  
    802 <p> Activity  Activity  {@code TitlesFragment}
    803 
    804 {@code DetailsFragment}
    805 {@code DetailsActivity} Activity</p>
    806 
    807 
    808 <p>
    809 <a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/index.html#Fragment">
    810 ApiDemos</a><a href="{@docRoot}resources/samples/get.html"> SDK </a> API Demos </p>
    811 
    812 
    813