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"></a>
     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  ( 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} Activity  {@link android.view.ViewGroup}  Activity  {@code &lt;fragment&gt;} 
     68 
     69 
     70 
     71  Activity  UI Activity 
     72 
     73 </p>
     74 
     75 <p> Activity  Activity  Activity  Activity 
     76 
     77 
     78 </p>
     79 
     80 
     81 <h2 id="Design"></h2>
     82 
     83 <p> Android 3.0 (API  11)  ()  UI 
     84  UI 
     85 
     86 
     87  Activity  Activity  Activity 
     88 
     89 </p>
     90 
     91 <p> &mdash;  Activity 
     92 
     93 
     94  Activity  ( 1 ) Activity 
     95 
     96 </p>
     97 
     98 <p> Activity  Activity 
     99 
    100 
    101 
    102 
    103 
    104  Activity  UI
    105 
    106 </p>
    107 
    108 <img src="{@docRoot}images/fundamentals/fragments.png" alt="" />
    109 <p class="img-caption"><strong> 1.</strong> UI  Activity Activity
    110 
    111 </p>
    112 
    113 <p> &mdash;  &mdash; Activity A<em></em>
    114 Activity A<em></em>Activity B<em></em>
    115 
    116 
    117  ( 1 )
    118 
    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} {@link android.app.Activity} 
    136  Activity  {@link android.app.Fragment#onCreate onCreate()}{@link android.app.Fragment#onStart onStart()}
    137 {@link android.app.Fragment#onPause onPause()}  {@link android.app.Fragment#onStop onStop()}
    138  Android  Activity 
    139 
    140 
    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  {@link android.view.View} () UI
    153  UI 
    154 </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> {@link android.app.Activity}  Activity 
    174 
    175 
    176 </dd>
    177 
    178   <dt>{@link android.app.ListFragment}</dt>
    179   <dd> ( {@link
    180 android.widget.SimpleCursorAdapter})  {@link android.app.ListActivity}  {@link
    181 android.app.ListFragment#onListItemClick(ListView,View,int,long) onListItemClick()}
    182 
    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}  {@link android.app.Fragment#onCreateView onCreateView()} 
    204 {@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">l</a>{@link android.app.Fragment#onCreateView onCreateView()}  
    208 {@link android.view.LayoutInflater} 
    209 </p>
    210 
    211 <p> {@link android.app.Fragment}  
    212 {@code example_fragment.xml} </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} XML <a href="{@docRoot}guide/topics/ui/index.html"></a>
    230 
    231 </p>
    232 </div>
    233 </div>
    234 
    235 <p> {@link android.app.Fragment#onCreateView
    236 onCreateView()}  {@code container}  {@link android.view.ViewGroup} ( Activity )
    237 
    238 {@code savedInstanceState}  {@link android.os.Bundle} (<a href="#Lifecycle"></a>)
    239 
    240 
    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} ()  ( {@code
    252 container} false &mdash;  true)
    253 </li>
    254 </ul>
    255 
    256 <p> Activity
    257 </p>
    258 
    259 
    260 
    261 <h3 id="Adding"> Activity </h3>
    262 
    263 <p> UI  Activity 
    264  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  {@link android.app.Fragment#onCreateView onCreateView()} 
    294 
    295  {@link android.view.View}  {@code &lt;fragment&gt;} 
    296 </p>
    297 
    298 <div class="note">
    299   <p><strong></strong> Activity  ()
    300 
    301  ID
    302 </p>
    303   <ul>
    304     <li> ID  {@code android: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  {@link
    314 android.view.ViewGroup} 
    315 </p>
    316   <p> Activity  () {@link android.app.FragmentTransaction}  API 
    317  {@link android.app.Activity}  {@link android.app.FragmentTransaction} 
    318 </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()}  {@link android.view.ViewGroup} ( ID )
    336 
    337 </p>
    338   <p>
    339 {@link android.app.FragmentTransaction}  {@link android.app.FragmentTransaction#commit} 
    340 </p>
    341   </li>
    342 </ul>
    343 
    344 
    345 <h4 id="AddingWithoutUI"> UI </h4>
    346 
    347 <p> Activity UI Activity  UI
    348 
    349 </p>
    350 
    351 <p> UI  {@link
    352 android.app.FragmentTransaction#add(Fragment,String)}  Activity  ( ID)
    353  Activity  {@link
    354 android.app.Fragment#onCreateView onCreateView()} 
    355 </p>
    356 
    357 <p> UI  &mdash;  UI  &mdash;  UI
    358 
    359  Activity  {@link android.app.FragmentManager#findFragmentByTag
    360 findFragmentByTag()}
    361 </p>
    362 
    363 <p> UI  Activity  SDK  {@code
    364 FragmentRetainInstance.java}  ( Android SDK Manager )<code>&lt;sdk_root&gt;/APIDemos/app/src/main/java/com/example/android/apis/app/FragmentRetainInstance.java</code>
    365 
    366 </p>
    367 
    368 
    369 
    370 <h2 id="Managing"></h2>
    371 
    372 <p> Activity  {@link android.app.FragmentManager} Activity  {@link android.app.Activity#getFragmentManager()}
    373 </p>
    374 
    375 <p> {@link android.app.FragmentManager} </p>
    376 
    377 <ul>
    378   <li> {@link
    379 android.app.FragmentManager#findFragmentById findFragmentById()} ( Activity  UI )  {@link android.app.FragmentManager#findFragmentByTag
    380 findFragmentByTag()} ( UI )  Activity 
    381 </li> 
    382   <li> {@link
    383 android.app.FragmentManager#popBackStack()} (<em></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}  {@link android.app.FragmentTransaction} ()
    392 
    393 </p>
    394 
    395 
    396 <h2 id="Transactions"></h2>
    397 
    398 <p> Activity 
    399  Activity  {@link
    400 android.app.FragmentTransaction} 
    401  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> {@link
    414 android.app.FragmentTransaction#add add()}{@link android.app.FragmentTransaction#remove remove()} {@link android.app.FragmentTransaction#replace replace()} 
    415 
    416  {@link android.app.FragmentTransaction#commit()} Activity
    417 </p>
    418 </dl>
    419 
    420 <p> {@link
    421 android.app.FragmentTransaction#addToBackStack addToBackStack()} {@link
    422 android.app.FragmentTransaction#commit()}
    423  Activity  []<em></em> 
    424 </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}  {@code R.id.fragment_container} ID 
    444  () {@link
    445 android.app.FragmentTransaction#addToBackStack addToBackStack()} []<em></em> 
    446 
    447 </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()} {@link android.app.FragmentTransaction#commit commit()}  []<em></em> 
    453 
    454 </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  {@link android.app.FragmentTransaction#addToBackStack(String) addToBackStack()}<em></em>
    467 
    468 
    469 </p>
    470 
    471 <p class="note"><strong></strong> {@link android.app.FragmentTransaction#setTransition setTransition()}
    472 
    473 </p>
    474 
    475 <p> {@link android.app.FragmentTransaction#commit()} 
    476  UI  () 
    477  UI  {@link
    478 android.app.FragmentManager#executePendingTransactions()} {@link android.app.FragmentTransaction#commit()} 
    479 
    480 </p>
    481 
    482 <p class="caution"><strong></strong> {@link
    483 android.app.FragmentTransaction#commit commit()}  Activity <a href="{@docRoot}guide/components/activities.html#SavingActivityState"></a> ( Activity )
    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}  Activity  Activity 
    496 </p>
    497 
    498 <p>{@link
    499 android.app.Fragment#getActivity()}  {@link android.app.Activity}  Activity 
    500 </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  {@link
    507 android.app.FragmentManager#findFragmentById findFragmentById()}  {@link
    508 android.app.FragmentManager#findFragmentByTag findFragmentByTag()}  {@link android.app.FragmentManager}  {@link android.app.Fragment} 
    509 </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}  A 
    526 </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  {@code OnArticleSelectedListener}  {@code onArticleSelected()}  A  B Activity  A  {@link
    540 android.app.Fragment#onAttach onAttach()}  ( Activity )  {@link android.app.Fragment#onAttach
    541 onAttach()}  {@link android.app.Activity} {@code OnArticleSelectedListener} 
    542 
    543 
    544 
    545 
    546 </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}  Activity  
    567 {@code OnArticleSelectedListener}  A  {@code OnArticleSelectedListener}  Activity 
    568 
    569  A 
    570 {@link android.app.ListFragment}  {@link android.app.ListFragment#onListItemClick
    571 onListItemClick()} {@code onArticleSelected()}  Activity 
    572 
    573 </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}  ID Activity ()  {@link
    592 android.content.ContentProvider} 
    593 </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>)  {@link
    605 android.app.Fragment#onCreate(Bundle) onCreate()}  {@link
    606 android.app.Fragment#setHasOptionsMenu(boolean) setHasOptionsMenu()} (
    607 {@link android.app.Fragment#onCreateOptionsMenu onCreateOptionsMenu()} )
    608 
    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()} {@link
    618 android.app.Fragment#onCreateContextMenu(ContextMenu,View,ContextMenu.ContextMenuInfo)
    619 onCreateContextMenu()} 
    620  {@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  {@link
    662 android.os.Bundle}  Activity  Activity 
    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  []<em></em>  Activity (<a href="{@docRoot}guide/components/tasks-and-back-stack.html"></a>) {@link
    673 android.app.FragmentTransaction#addToBackStack(String) addToBackStack()}  Activity 
    674 
    675 
    676 
    677 
    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}  {@link android.app.Fragment#getActivity()} Activity  {@link android.app.Fragment#getActivity()}
    687 
    688  Activity {@link android.app.Fragment#getActivity()} 
    689 </p>
    690 
    691 
    692 <h3 id="CoordinatingWithActivity"> Activity </h3>
    693 
    694 <p> Activity Activity 
    695 
    696  Activity  {@link android.app.Activity#onPause} Activity  {@link android.app.Fragment#onPause}
    697 </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}  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  Activity 
    719  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  Activity 
    740 </p>
    741 
    742 <p class="note"><strong></strong> Activity  
    743 <a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.html">{@code
    744 FragmentLayout.java}</a></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>Activity  {@code fragment_layout.xml}</p>
    752 
    753 {@sample development/samples/ApiDemos/res/layout-land/fragment_layout.xml layout}
    754 
    755 <p> Activity  {@code TitlesFragment} () {@link android.widget.FrameLayout} () 
    756 
    757 
    758  {@link android.widget.FrameLayout}
    759 </p>
    760 
    761 <p>
    762  {@code res/layout-land/fragment_layout.xml} 
    763 </p>
    764 
    765 <p> {@code res/layout/fragment_layout.xml} 
    766 </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> Activity  ( {@link
    780 android.widget.FrameLayout}) Activity ()
    781 
    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}  ({@code DetailsFragment} ) {@code DetailsActivity} Activity 
    792 
    793 
    794 </p>
    795 
    796 <p> {@code DetailsFragment}  {@code DetailsActivity}
    797 </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}  {@code DetailsFragment} {@code DetailsActivity} ( Activity)
    803 
    804 
    805 </p>
    806 
    807 
    808 <p> ()<a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/index.html#Fragment">ApiDemos</a>  API Demos  ( <a href="{@docRoot}resources/samples/get.html">SDK </a>)
    809 
    810 </p>
    811 
    812 
    813