1 page.title= 2 page.tags=alertdialog,dialogfragment 3 4 @jd:body 5 6 7 8 <div id="qv-wrapper"> 9 <div id="qv"> 10 <h2></h2> 11 <ol> 12 <li><a href="#DialogFragment"></a></li> 13 <li><a href="#AlertDialog"></a> 14 <ol> 15 <li><a href="#AddingButtons"></a></li> 16 <li><a href="#AddingAList"></a></li> 17 <li><a href="#CustomLayout"></a></li> 18 </ol> 19 </li> 20 <li><a href="#PassingEvents"></a></li> 21 <li><a href="#ShowingADialog"></a></li> 22 <li><a href="#FullscreenDialog"></a> 23 <ol> 24 <li><a href="#ActivityAsDialog"> Activity </a></li> 25 </ol> 26 </li> 27 <li><a href="#DismissingADialog"></a></li> 28 </ol> 29 30 <h2></h2> 31 <ol> 32 <li>{@link android.app.DialogFragment}</li> 33 <li>{@link android.app.AlertDialog}</li> 34 </ol> 35 36 <h2></h2> 37 <ol> 38 <li><a href="{@docRoot}design/building-blocks/dialogs.html"></a></li> 39 <li><a href="{@docRoot}guide/topics/ui/controls/pickers.html"></a> (/)</li> 40 </ol> 41 </div> 42 </div> 43 44 <p> 45 46 </p> 47 48 <div class="note design"> 49 <p><strong></strong></p> 50 <p><a href="{@docRoot}design/building-blocks/dialogs.html"></a> 51 </p> 52 </div> 53 54 <img src="{@docRoot}images/ui/dialogs.png" /> 55 56 <p>{@link android.app.Dialog} {@link android.app.Dialog} 57 58 </p> 59 <dl> 60 <dt>{@link android.app.AlertDialog}</dt> 61 <dd> 62 </dd> 63 <dt>{@link android.app.DatePickerDialog} {@link android.app.TimePickerDialog}</dt> 64 <dd> UI</dd> 65 </dl> 66 67 <div class="sidebox"> 68 <h2> ProgressDialog</h2> 69 <p>Android 70 {@link android.app.ProgressDialog} <a href="{@docRoot}design/building-blocks/progress.html"> Activity</a> {@link android.widget.ProgressBar} 71 72 73 </p> 74 </div> 75 76 <p> {@link android.support.v4.app.DialogFragment} 77 {@link android.support.v4.app.DialogFragment} {@link android.app.Dialog} 78 79 80 </p> 81 82 <p> {@link android.support.v4.app.DialogFragment} []<em></em> 83 84 {@link 85 android.support.v4.app.DialogFragment} {@link 86 android.support.v4.app.Fragment} UI UI () 87 88 </p> 89 90 <p> {@link android.app.AlertDialog} {@link 91 android.support.v4.app.DialogFragment} 92 <a href="{@docRoot}guide/topics/ui/controls/pickers.html"></a> 93 </p> 94 95 <p class="note"><strong></strong>{@link android.app.DialogFragment} Android 3.0 (API 11) <a href="{@docRoot}tools/support-library/index.html"></a> {@link 96 android.support.v4.app.DialogFragment} 97 98 Android 1.6 {@link android.support.v4.app.DialogFragment} API 99 100 API 11 {@link 101 android.app.DialogFragment} API 102 103 <code>android.support.v4.app.DialogFragment</code> <em></em><code>android.app.DialogFragment</code> 104 105 </p> 106 107 108 <h2 id="DialogFragment"></h2> 109 110 <p> — <a href="{@docRoot}design/building-blocks/dialogs.html"></a> — 111 {@link android.support.v4.app.DialogFragment} 112 {@link android.support.v4.app.DialogFragment#onCreateDialog 113 onCreateDialog()} {@link android.app.AlertDialog} 114 115 </p> 116 117 <p> {@link android.support.v4.app.DialogFragment} 118 {@link android.app.AlertDialog}</p> 119 120 <pre> 121 public class FireMissilesDialogFragment extends DialogFragment { 122 @Override 123 public Dialog onCreateDialog(Bundle savedInstanceState) { 124 // Use the Builder class for convenient dialog construction 125 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 126 builder.setMessage(R.string.dialog_fire_missiles) 127 .setPositiveButton(R.string.fire, new DialogInterface.OnClickListener() { 128 public void onClick(DialogInterface dialog, int id) { 129 // FIRE ZE MISSILES! 130 } 131 }) 132 .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 133 public void onClick(DialogInterface dialog, int id) { 134 // User cancelled the dialog 135 } 136 }); 137 // Create the AlertDialog object and return it 138 return builder.create(); 139 } 140 } 141 </pre> 142 143 <div class="figure" style="width:290px;margin:0 0 0 20px"> 144 <img src="{@docRoot}images/ui/dialog_buttons.png" alt="" /> 145 <p class="img-caption"><strong> 1.</strong> 146 </p> 147 </div> 148 149 <p> {@link 150 android.support.v4.app.DialogFragment#show show()} 1 151 </p> 152 153 <p> {@link android.app.AlertDialog.Builder} API 154 </p> 155 156 <p> {@link android.support.v4.app.DialogFragment} <a href="{@docRoot}guide/components/fragments.html#Lifecycle"></a> 157 158 159 160 161 162 163 164 <h2 id="AlertDialog"></h2> 165 166 167 <p>{@link android.app.AlertDialog} 2 3 168 169 </p> 170 171 <div class="figure" style="width:311px;margin-top:0"> 172 <img src="{@docRoot}images/ui/dialogs_regions.png" alt="" style="margin-bottom:0" /> 173 <p class="img-caption"><strong> 2.</strong></p> 174 </div> 175 176 <ol> 177 <li><b></b> 178 <p> 179 ( 1 ) 180 </li> 181 <li><b></b> 182 <p></p></li> 183 <li><b></b> 184 <p> 3 </p></li> 185 </ol> 186 187 <p>{@link android.app.AlertDialog.Builder} API () {@link android.app.AlertDialog} 188 189 </p> 190 191 <p> {@link android.app.AlertDialog}</p> 192 193 <pre> 194 <b>// 1. Instantiate an {@link android.app.AlertDialog.Builder} with its constructor</b> 195 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 196 197 <b>// 2. Chain together various setter methods to set the dialog characteristics</b> 198 builder.setMessage(R.string.dialog_message) 199 .setTitle(R.string.dialog_title); 200 201 <b>// 3. Get the {@link android.app.AlertDialog} from {@link android.app.AlertDialog.Builder#create()}</b> 202 AlertDialog dialog = builder.create(); 203 </pre> 204 205 <p> {@link android.app.AlertDialog.Builder} 206 </p> 207 208 209 210 211 <h3 id="AddingButtons"></h3> 212 213 <p> 2 {@link android.app.AlertDialog.Builder#setPositiveButton setPositiveButton()} 214 {@link android.app.AlertDialog.Builder#setNegativeButton setNegativeButton()} 215 </p> 216 217 <pre style="clear:right"> 218 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 219 // Add the buttons 220 builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { 221 public void onClick(DialogInterface dialog, int id) { 222 // User clicked OK button 223 } 224 }); 225 builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 226 public void onClick(DialogInterface dialog, int id) { 227 // User cancelled the dialog 228 } 229 }); 230 // Set other dialog properties 231 ... 232 233 // Create the AlertDialog 234 AlertDialog dialog = builder.create(); 235 </pre> 236 237 <p><code>set...Button()</code> <a href="{@docRoot}guide/topics/resources/string-resource.html"></a>{@link android.content.DialogInterface.OnClickListener} 238 239 240 </p> 241 242 <p> 3 </p> 243 <dl> 244 <dt></dt> 245 <dd> ()</dd> 246 <dt></dt> 247 <dd></dd> 248 <dt></dt> 249 <dd> 250 251 [] </dd> 252 </dl> 253 254 <p> {@link 255 android.app.AlertDialog}</p> 256 257 258 259 <div class="figure" style="width:290px;margin:0 0 0 40px"> 260 <img src="{@docRoot}images/ui/dialog_list.png" alt="" /> 261 <p class="img-caption"><strong> 3.</strong> 262 </p> 263 </div> 264 265 <h3 id="AddingAList"></h3> 266 267 <p>{@link android.app.AlertDialog} API 3 </p> 268 <ul> 269 <li></li> 270 <li> ()</li> 271 <li> ()</li> 272 </ul> 273 274 <p> 3 {@link android.app.AlertDialog.Builder#setItems setItems()} 275 </p> 276 277 <pre style="clear:right"> 278 @Override 279 public Dialog onCreateDialog(Bundle savedInstanceState) { 280 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 281 builder.setTitle(R.string.pick_color) 282 .setItems(R.array.colors_array, new DialogInterface.OnClickListener() { 283 public void onClick(DialogInterface dialog, int which) { 284 // The 'which' argument contains the index position 285 // of the selected item 286 } 287 }); 288 return builder.create(); 289 } 290 </pre> 291 292 <p> {@link android.app.AlertDialog.Builder#setTitle setTitle()} 293 294 {@link 295 android.app.AlertDialog.Builder#setItems setItems()} {@link 296 android.app.AlertDialog.Builder#setAdapter setAdapter()} 297 298 {@link android.widget.ListAdapter} () 299 </p> 300 301 <p> {@link android.widget.ListAdapter} {@link android.support.v4.content.Loader} 302 303 <a href="{@docRoot}guide/topics/ui/declaring-layout.html#AdapterViews"></a><a href="{@docRoot}guide/components/loaders.html"></a> 304 305 306 </p> 307 308 <p class="note"><strong></strong> 309 </p> 310 311 <div class="figure" style="width:290px;margin:-30px 0 0 40px"> 312 <img src="{@docRoot}images/ui/dialog_checkboxes.png" /> 313 <p class="img-caption"><strong> 4.</strong> 314 </p> 315 </div> 316 317 318 <h4 id="Checkboxes"></h4> 319 320 <p> () () 321 {@link android.app.AlertDialog.Builder#setMultiChoiceItems(Cursor,String,String, 322 DialogInterface.OnMultiChoiceClickListener) setMultiChoiceItems()} 323 {@link android.app.AlertDialog.Builder#setSingleChoiceItems(int,int,DialogInterface.OnClickListener) 324 setSingleChoiceItems()} 325 </p> 326 327 <p> 4 {@link java.util.ArrayList} 328 329 </p> 330 331 <pre style="clear:right"> 332 @Override 333 public Dialog onCreateDialog(Bundle savedInstanceState) { 334 mSelectedItems = new ArrayList(); // Where we track the selected items 335 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 336 // Set the dialog title 337 builder.setTitle(R.string.pick_toppings) 338 // Specify the list array, the items to be selected by default (null for none), 339 // and the listener through which to receive callbacks when items are selected 340 .setMultiChoiceItems(R.array.toppings, null, 341 new DialogInterface.OnMultiChoiceClickListener() { 342 @Override 343 public void onClick(DialogInterface dialog, int which, 344 boolean isChecked) { 345 if (isChecked) { 346 // If the user checked the item, add it to the selected items 347 mSelectedItems.add(which); 348 } else if (mSelectedItems.contains(which)) { 349 // Else, if the item is already in the array, remove it 350 mSelectedItems.remove(Integer.valueOf(which)); 351 } 352 } 353 }) 354 // Set the action buttons 355 .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { 356 @Override 357 public void onClick(DialogInterface dialog, int id) { 358 // User clicked OK, so save the mSelectedItems results somewhere 359 // or return them to the component that opened the dialog 360 ... 361 } 362 }) 363 .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 364 @Override 365 public void onClick(DialogInterface dialog, int id) { 366 ... 367 } 368 }); 369 370 return builder.create(); 371 } 372 </pre> 373 374 <p> {@link 375 android.app.AlertDialog.Builder#setSingleChoiceItems(int,int,DialogInterface.OnClickListener) 376 setSingleChoiceItems()} 377 378 379 </p> 380 381 382 383 384 385 <h3 id="CustomLayout"></h3> 386 387 <div class="figure" style="width:290px;margin:-30px 0 0 40px"> 388 <img src="{@docRoot}images/ui/dialog_custom.png" alt="" /> 389 <p class="img-caption"><strong> 5.</strong></p> 390 </div> 391 392 <p> {@link 393 android.app.AlertDialog.Builder} {@link 394 android.app.AlertDialog.Builder#setView setView()} {@link android.app.AlertDialog} 395 </p> 396 397 <p> {@link android.app.AlertDialog.Builder} 398 </p> 399 400 <p> 5 </p> 401 402 <p style="clear:right" class="code-caption">res/layout/dialog_signin.xml</p> 403 <pre> 404 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 405 android:orientation="vertical" 406 android:layout_width="wrap_content" 407 android:layout_height="wrap_content"> 408 <ImageView 409 android:src="@drawable/header_logo" 410 android:layout_width="match_parent" 411 android:layout_height="64dp" 412 android:scaleType="center" 413 android:background="#FFFFBB33" 414 android:contentDescription="@string/app_name" /> 415 <EditText 416 android:id="@+id/username" 417 android:inputType="textEmailAddress" 418 android:layout_width="match_parent" 419 android:layout_height="wrap_content" 420 android:layout_marginTop="16dp" 421 android:layout_marginLeft="4dp" 422 android:layout_marginRight="4dp" 423 android:layout_marginBottom="4dp" 424 android:hint="@string/username" /> 425 <EditText 426 android:id="@+id/password" 427 android:inputType="textPassword" 428 android:layout_width="match_parent" 429 android:layout_height="wrap_content" 430 android:layout_marginTop="4dp" 431 android:layout_marginLeft="4dp" 432 android:layout_marginRight="4dp" 433 android:layout_marginBottom="16dp" 434 android:fontFamily="sans-serif" 435 android:hint="@string/password"/> 436 </LinearLayout> 437 </pre> 438 439 <p class="note"><strong></strong> {@link android.widget.EditText} {@code "textPassword"} {@code "sans-serif"} 440 441 442 </p> 443 444 <p> {@link android.support.v4.app.DialogFragment} {@link android.app.Activity#getLayoutInflater()} {@link android.view.LayoutInflater}{@link android.view.LayoutInflater#inflate inflate()} ( ID) {@link android.app.AlertDialog#setView setView()} 445 446 447 448 449 450 </p> 451 452 <pre> 453 @Override 454 public Dialog onCreateDialog(Bundle savedInstanceState) { 455 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 456 // Get the layout inflater 457 LayoutInflater inflater = getActivity().getLayoutInflater(); 458 459 // Inflate and set the layout for the dialog 460 // Pass null as the parent view because its going in the dialog layout 461 builder.setView(inflater.inflate(R.layout.dialog_signin, null)) 462 // Add action buttons 463 .setPositiveButton(R.string.signin, new DialogInterface.OnClickListener() { 464 @Override 465 public void onClick(DialogInterface dialog, int id) { 466 // sign in the user ... 467 } 468 }) 469 .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 470 public void onClick(DialogInterface dialog, int id) { 471 LoginDialogFragment.this.getDialog().cancel(); 472 } 473 }); 474 return builder.create(); 475 } 476 </pre> 477 478 <div class="note"> 479 <p><strong></strong> {@link android.app.Activity} {@link android.app.Dialog} API 480 481 Activity <a href="{@docRoot}guide/topics/manifest/activity-element.html">{@code 482 <activity>}</a> 483 {@link android.R.style#Theme_Holo_Dialog Theme.Holo.Dialog} 484 </p> 485 486 <pre> 487 <activity android:theme="@android:style/Theme.Holo.Dialog" > 488 </pre> 489 <p>Activity </p> 490 </div> 491 492 493 494 <h2 id="PassingEvents"></h2> 495 496 <p> {@link android.support.v4.app.DialogFragment} Activity 497 498 499 500 501 </p> 502 503 <p> Activity {@link android.support.v4.app.DialogFragment} 504 </p> 505 506 <pre> 507 public class NoticeDialogFragment extends DialogFragment { 508 509 /* The activity that creates an instance of this dialog fragment must 510 * implement this interface in order to receive event callbacks. 511 * Each method passes the DialogFragment in case the host needs to query it. */ 512 public interface NoticeDialogListener { 513 public void onDialogPositiveClick(DialogFragment dialog); 514 public void onDialogNegativeClick(DialogFragment dialog); 515 } 516 517 // Use this instance of the interface to deliver action events 518 NoticeDialogListener mListener; 519 520 // Override the Fragment.onAttach() method to instantiate the NoticeDialogListener 521 @Override 522 public void onAttach(Activity activity) { 523 super.onAttach(activity); 524 // Verify that the host activity implements the callback interface 525 try { 526 // Instantiate the NoticeDialogListener so we can send events to the host 527 mListener = (NoticeDialogListener) activity; 528 } catch (ClassCastException e) { 529 // The activity doesn't implement the interface, throw exception 530 throw new ClassCastException(activity.toString() 531 + " must implement NoticeDialogListener"); 532 } 533 } 534 ... 535 } 536 </pre> 537 538 <p> Activity {@code NoticeDialogListener} 539 540 </p> 541 542 <pre> 543 public class MainActivity extends FragmentActivity 544 implements NoticeDialogFragment.NoticeDialogListener{ 545 ... 546 547 public void showNoticeDialog() { 548 // Create an instance of the dialog fragment and show it 549 DialogFragment dialog = new NoticeDialogFragment(); 550 dialog.show(getSupportFragmentManager(), "NoticeDialogFragment"); 551 } 552 553 // The dialog fragment receives a reference to this Activity through the 554 // Fragment.onAttach() callback, which it uses to call the following methods 555 // defined by the NoticeDialogFragment.NoticeDialogListener interface 556 @Override 557 public void onDialogPositiveClick(DialogFragment dialog) { 558 // User touched the dialog's positive button 559 ... 560 } 561 562 @Override 563 public void onDialogNegativeClick(DialogFragment dialog) { 564 // User touched the dialog's negative button 565 ... 566 } 567 } 568 </pre> 569 570 <p> Activity {@code NoticeDialogListener} — {@link android.support.v4.app.Fragment#onAttach onAttach()} Activity — Activity 571 572 573 </p> 574 575 <pre> 576 public class NoticeDialogFragment extends DialogFragment { 577 ... 578 579 @Override 580 public Dialog onCreateDialog(Bundle savedInstanceState) { 581 // Build the dialog and set up the button click handlers 582 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 583 builder.setMessage(R.string.dialog_fire_missiles) 584 .setPositiveButton(R.string.fire, new DialogInterface.OnClickListener() { 585 public void onClick(DialogInterface dialog, int id) { 586 // Send the positive button event back to the host activity 587 mListener.onDialogPositiveClick(NoticeDialogFragment.this); 588 } 589 }) 590 .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 591 public void onClick(DialogInterface dialog, int id) { 592 // Send the negative button event back to the host activity 593 mListener.onDialogNegativeClick(NoticeDialogFragment.this); 594 } 595 }); 596 return builder.create(); 597 } 598 } 599 </pre> 600 601 602 603 <h2 id="ShowingADialog"></h2> 604 605 <p> {@link 606 android.support.v4.app.DialogFragment} {@link android.support.v4.app.DialogFragment#show 607 show()} {@link android.support.v4.app.FragmentManager} 608 </p> 609 610 <p> {@link android.support.v4.app.FragmentManager} 611 {@link android.support.v4.app.FragmentActivity} 612 {@link android.support.v4.app.FragmentActivity#getSupportFragmentManager()} {@link 613 android.support.v4.app.Fragment} {@link 614 android.support.v4.app.Fragment#getFragmentManager()}</p> 615 616 <pre> 617 public void confirmFireMissiles() { 618 DialogFragment newFragment = new FireMissilesDialogFragment(); 619 newFragment.show(getSupportFragmentManager(), "missiles"); 620 } 621 </pre> 622 623 <p> {@code "missiles"} 624 625 {@link android.support.v4.app.FragmentManager#findFragmentByTag 626 findFragmentByTag()} </p> 627 628 629 630 631 <h2 id="FullscreenDialog"></h2> 632 633 <p> UI UI () 634 635 {@link android.support.v4.app.DialogFragment} {@link 636 android.support.v4.app.Fragment} 637 </p> 638 639 <p> {@link android.app.AlertDialog.Builder AlertDialog.Builder} {@link android.app.Dialog} 640 {@link android.support.v4.app.DialogFragment} UI {@link android.support.v4.app.DialogFragment#onCreateView 641 onCreateView()} 642 643 644 </p> 645 646 <p> {@link android.support.v4.app.DialogFragment} ( <code>purchase_items.xml</code> ) 647 </p> 648 649 <pre> 650 public class CustomDialogFragment extends DialogFragment { 651 /** The system calls this to get the DialogFragment's layout, regardless 652 of whether it's being displayed as a dialog or an embedded fragment. */ 653 @Override 654 public View onCreateView(LayoutInflater inflater, ViewGroup container, 655 Bundle savedInstanceState) { 656 // Inflate the layout to use as dialog or embedded fragment 657 return inflater.inflate(R.layout.purchase_items, container, false); 658 } 659 660 /** The system calls this only when creating the layout in a dialog. */ 661 @Override 662 public Dialog onCreateDialog(Bundle savedInstanceState) { 663 // The only reason you might override this method when using onCreateView() is 664 // to modify any dialog characteristics. For example, the dialog includes a 665 // title by default, but your custom layout might not need it. So here you can 666 // remove the dialog title, but you must call the superclass to get the Dialog. 667 Dialog dialog = super.onCreateDialog(savedInstanceState); 668 dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 669 return dialog; 670 } 671 } 672 </pre> 673 674 <p> UI 675 </p> 676 677 <pre> 678 public void showDialog() { 679 FragmentManager fragmentManager = getSupportFragmentManager(); 680 CustomDialogFragment newFragment = new CustomDialogFragment(); 681 682 if (mIsLargeLayout) { 683 // The device is using a large layout, so show the fragment as a dialog 684 newFragment.show(fragmentManager, "dialog"); 685 } else { 686 // The device is smaller, so show the fragment fullscreen 687 FragmentTransaction transaction = fragmentManager.beginTransaction(); 688 // For a little polish, specify a transition animation 689 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 690 // To make it fullscreen, use the 'content' root view as the container 691 // for the fragment, which is always the root view for the activity 692 transaction.add(android.R.id.content, newFragment) 693 .addToBackStack(null).commit(); 694 } 695 } 696 </pre> 697 698 <p><a href="{@docRoot}guide/components/fragments.html"></a> 699 </p> 700 701 <p><code>mIsLargeLayout</code> () 702 703 <a href="{@docRoot}guide/topics/resources/providing-resources.html#AlternativeResources"></a><a href="{@docRoot}guide/topics/resources/more-resources.html#Bool"></a> 704 705 2 706 </p> 707 708 <p class="code-caption">res/values/bools.xml</p> 709 <pre> 710 <!-- Default boolean values --> 711 <resources> 712 <bool name="large_layout">false</bool> 713 </resources> 714 </pre> 715 716 <p class="code-caption">res/values-large/bools.xml</p> 717 <pre> 718 <!-- Large screen boolean values --> 719 <resources> 720 <bool name="large_layout">true</bool> 721 </resources> 722 </pre> 723 724 <p> Activity {@link android.app.Activity#onCreate onCreate()} {@code mIsLargeLayout} 725 </p> 726 727 <pre> 728 boolean mIsLargeLayout; 729 730 @Override 731 public void onCreate(Bundle savedInstanceState) { 732 super.onCreate(savedInstanceState); 733 setContentView(R.layout.activity_main); 734 735 mIsLargeLayout = getResources().getBoolean(R.bool.large_layout); 736 } 737 </pre> 738 739 740 741 <h3 id="ActivityAsDialog"> Activity </h3> 742 743 <p> {@link android.app.Activity} UI 744 745 Activity Activity 746 747 748 </p> 749 750 <p> Activity <a href="{@docRoot}guide/topics/manifest/activity-element.html">{@code 751 <activity>}</a> {@link android.R.style#Theme_Holo_DialogWhenLarge Theme.Holo.DialogWhenLarge} 752 753 </p> 754 755 <pre> 756 <activity android:theme="@android:style/Theme.Holo.DialogWhenLarge" > 757 </pre> 758 759 <p> Activity <a href="{@docRoot}guide/topics/ui/themes.html"></a></p> 760 761 762 763 <h2 id="DismissingADialog"></h2> 764 765 <p> {@link android.app.AlertDialog.Builder} 766 </p> 767 768 <p> 769 {@link 770 android.support.v4.app.DialogFragment} {@link android.support.v4.app.DialogFragment#dismiss()} 771 </p> 772 773 <p> {@link 774 android.support.v4.app.DialogFragment} {@link 775 android.support.v4.app.DialogFragment#onDismiss onDismiss()} 776 </p> 777 778 <p><em></em> 779 []<em></em> {@link 780 android.app.Dialog} {@link android.app.Dialog#cancel()} ( [] ) 781 782 </p> 783 784 <p> {@link 785 android.support.v4.app.DialogFragment} {@link android.support.v4.app.DialogFragment#onCancel onCancel()} 786 </p> 787 788 <p class="note"><strong></strong> {@link android.support.v4.app.DialogFragment#onCancel onCancel()} 789 {@link android.support.v4.app.DialogFragment#onDismiss onDismiss()} 790 {@link android.app.Dialog#dismiss Dialog.dismiss()} {@link 791 android.support.v4.app.DialogFragment#dismiss DialogFragment.dismiss()} {@link android.support.v4.app.DialogFragment#onDismiss onDismiss()}<em></em>{@link android.support.v4.app.DialogFragment#onCancel onCancel()} 792 793 794 <em></em> {@link android.support.v4.app.DialogFragment#dismiss dismiss()} 795 796 </p> 797 798 799