1page.title=Dialogs
2@jd:body
3
4<p>Dialogs prompt the user for decisions or additional information required by the app to continue a
5task. Such requests can range from simple Cancel/OK decisions to more complex layouts asking the
6user to adjust settings or enter text.</p>
7
8<img src="{@docRoot}design/media/dialogs_main.png">
9
10<div class="with-callouts">
11
12<ol>
13  <li>
14  <h4>Optional title region</h4>
15  <p>The title introduces the content of your dialog. It can, for example, identify the name of a
16   setting that the user is about to change, or request a decision.</p>
17  </li>
18  <li>
19  <h4>Content area</h4>
20  <p>Dialog content varies widely. For settings dialogs, a dialog may contain UI elements such as
21   sliders, text fields, checkboxes, or radio buttons that allow the user to change app or system
22   settings. In other cases, such as alerts, the content may consist solely of text that provides
23   further context for a user decision.</p>
24  </li>
25
26  <li>
27  <h4>Action buttons</h4>
28  <p>Action buttons are typically Cancel and/or OK, with OK indicating the preferred or most likely action. However, if the options consist of specific actions such as Close or Wait rather than a confirmation or cancellation of the action described in the content, then all the buttons should be active verbs. Order actions following these rules:</p>
29    <ul>
30    
31    <li>The dismissive action of a dialog is always on the left. Dismissive actions return to the user to the previous state.</li>
32    <li>The affirmative actions are on the right. Affirmative actions continue progress toward the user goal that triggered the dialog.</li>
33    </ul>
34  </li>
35</ol>
36</div>
37
38<img src="{@docRoot}design/media/dialogs_examples.png">
39<div class="figure-caption">
40  Samples of typical dialog use in Android.
41</div>
42
43<h2 id="alerts">Alerts</h2>
44
45<p>Alerts inform the user about a situation that requires their confirmation or acknowledgement before
46proceeding. They differ slightly in appearance based upon the severity and impact of the message
47conveyed.</p>
48
49<div class="layout-content-row">
50  <div class="layout-content-col span-8">
51
52    <img src="{@docRoot}design/media/dialogs_w_no_title.png">
53
54  </div>
55  <div class="layout-content-col span-5">
56
57<h4>Alerts without title bars</h4>
58<p>Most alerts don't need titles. Usually the decision doesn't have a severe impact and can be summed
59up succinctly in a sentence or two. The content area should either ask a question (such as "Delete
60this conversation?") or make a clear statement whose relationship to the action buttons is obvious.</p>
61
62  </div>
63</div>
64
65
66<div class="layout-content-row">
67  <div class="layout-content-col span-8">
68
69    <img src="{@docRoot}design/media/dialogs_w_title.png">
70
71  </div>
72  <div class="layout-content-col span-5">
73
74<h4>Alerts with title bars</h4>
75<p>Use alerts with title bars sparingly. They are appropriate only when a high-risk operation involving
76potential loss of data, connectivity, extra charges, and so on requires a clear question or
77statement (the title) and some additional explanation (in the content area).</p>
78<p>Keep the question or statement short: for example, "Erase USB storage?" Avoid apologies. A user
79should be able to skip the content completely and still have a clear idea of what choices are
80available based on the title and the text of the action buttons.</p>
81
82  </div>
83</div>
84<p>When crafting a confirmation dialog, make the title meaningful by echoing the requested action.</p>
85
86<div class="layout-content-row">
87  <div class="layout-content-col span-4">
88    <div class="do-dont-label bad">Don't</div>
89      <table class="ui-table bad">
90      <thead>
91        <tr>
92          <th class="label">
93          Are you sure?
94          </th>
95        </tr>
96      </thead>
97      </table>
98  </div>
99  <div class="layout-content-col span-4">
100    <div class="do-dont-label bad">Don't</div>
101      <table class="ui-table bad">
102      <thead>
103        <tr>
104          <th class="label">
105          Warning!
106          </th>
107        </tr>
108      </thead>
109      </table>
110  </div>
111  <div class="layout-content-col span-5">
112    <div class="do-dont-label good">Do</div>
113      <table class="ui-table good">
114      <thead>
115        <tr>
116          <th class="label">
117          Erase USB storage?
118          </th>
119        </tr>
120      </thead>
121      </table>
122  </div>
123</div>
124
125<div class="note develop">
126<p><strong>Developer Guide</strong></p>
127  <p>For information about how to build dialogs in your app,
128  see the <a href="{@docRoot}guide/topics/ui/dialogs.html">Dialogs</a> API guide.</p>
129</div>
130
131<h2 id="popups">Popups</h2>
132
133<p>Popups are lightweight version of dialogs that require a single selection from the user. Popups
134don't have have explicit buttons that accept or cancel the operation. Instead, making a selection
135advances the workflow, and simply touching outside the popup dismisses it.</p>
136
137<img src="{@docRoot}design/media/dialogs_popups_example.png">
138
139
140<h2 id="toasts">Toasts</h2>
141
142
143<div class="layout-content-row">
144  <div class="layout-content-col span-6">
145
146    <div class="vspace size-6"></div>
147
148<p>Toasts provide lightweight feedback about an operation in a small popup. For example, navigating
149away from an email before you send it triggers a "Draft saved" toast to let you know that you can
150continue editing later. Toasts automatically disappear after a timeout.</p>
151
152  </div>
153  <div class="layout-content-col span-7">
154
155    <img src="{@docRoot}design/media/dialogs_toasts.png">
156
157  </div>
158</div>
159
160
161<div class="note develop">
162<p><strong>Developer Guide</strong></p>
163  <p>For information about how to create toasts,
164  see the <a href="{@docRoot}guide/topics/ui/notifiers/toasts.html">Toasts</a> API guide.</p>
165</div>
166