blob: 37dcab5e4da02f888d9f08940cc57815a37a8ac5 [file] [log] [blame]
Roman Nurik73790462011-12-22 16:18:19 -08001<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>
6
7Android Design - Selection
8 </title>
9 <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
10 <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumitalic">
11 <link rel="stylesheet" href="../static/yui-3.3.0-reset-min.css">
12 <link rel="stylesheet" href="../static/default.css">
13
14 </head>
15 <body>
16
17 <div id="page-container">
18
19 <div id="page-header"><a href="../index.html">Android Design</a></div>
20
21 <div id="main-row">
22
23 <ul id="nav">
24
25 <li class="nav-section">
26 <div class="nav-section-header"><a href="../index.html">Get Started</a></div>
27 <ul>
28 <li><a href="../get-started/creative-vision.html">Creative Vision</a></li>
29 <li><a href="../get-started/principles.html">Design Principles</a></li>
30 <li><a href="../get-started/ui-overview.html">UI Overview</a></li>
31 </ul>
32 </li>
33
34 <li class="nav-section">
35 <div class="nav-section-header"><a href="../style/index.html">Style</a></div>
36 <ul>
37 <li><a href="../style/devices-displays.html">Devices and Displays</a></li>
38 <li><a href="../style/themes.html">Themes</a></li>
39 <li><a href="../style/touch-feedback.html">Touch Feedback</a></li>
40 <li><a href="../style/metrics-grids.html">Metrics and Grids</a></li>
41 <li><a href="../style/typography.html">Typography</a></li>
42 <li><a href="../style/color.html">Color</a></li>
43 <li><a href="../style/iconography.html">Iconography</a></li>
44 <li><a href="../style/writing.html">Writing Style</a></li>
45 </ul>
46 </li>
47
48 <li class="nav-section">
49 <div class="nav-section-header"><a href="../patterns/index.html">Patterns</a></div>
50 <ul>
51 <li><a href="../patterns/new-4-0.html">New in Android 4.0</a></li>
52 <li><a href="../patterns/gestures.html">Gestures</a></li>
53 <li><a href="../patterns/app-structure.html">App Structure</a></li>
54 <li><a href="../patterns/navigation.html">Navigation</a></li>
55 <li><a href="../patterns/actionbar.html">Action Bar</a></li>
56 <li><a href="../patterns/multi-pane-layouts.html">Multi-pane Layouts</a></li>
57 <li><a href="../patterns/swipe-views.html">Swipe Views</a></li>
58 <li><a href="../patterns/selection.html">Selection</a></li>
59 <li><a href="../patterns/notifications.html">Notifications</a></li>
60 <li><a href="../patterns/compatibility.html">Compatibility</a></li>
61 <li><a href="../patterns/pure-android.html">Pure Android</a></li>
62 </ul>
63 </li>
64
65 <li class="nav-section">
66 <div class="nav-section-header"><a href="../building-blocks/index.html">Building Blocks</a></div>
67 <ul>
68 <li><a href="../building-blocks/tabs.html">Tabs</a></li>
69 <li><a href="../building-blocks/lists.html">Lists</a></li>
70 <li><a href="../building-blocks/grid-lists.html">Grid Lists</a></li>
71 <li><a href="../building-blocks/scrolling.html">Scrolling</a></li>
72 <li><a href="../building-blocks/spinners.html">Spinners</a></li>
73 <li><a href="../building-blocks/buttons.html">Buttons</a></li>
74 <li><a href="../building-blocks/text-fields.html">Text Fields</a></li>
75 <li><a href="../building-blocks/seek-bars.html">Seek Bars</a></li>
76 <li><a href="../building-blocks/progress.html">Progress &amp; Activity</a></li>
77 <li><a href="../building-blocks/switches.html">Switches</a></li>
78 <li><a href="../building-blocks/dialogs.html">Dialogs</a></li>
79 <li><a href="../building-blocks/pickers.html">Pickers</a></li>
80 </ul>
81 </li>
82
83 <li>
Roman Nurikc894fb72012-01-10 23:59:20 -080084 <div id="back-dac-section"><a href="../../index.html">Developers</a></div>
Roman Nurik73790462011-12-22 16:18:19 -080085 </li>
86
87 </ul>
88
89 <div id="content">
90
91
92 <div class="layout-content-row content-header">
93 <div class="layout-content-col span-9">
94 <h2>Selection</h2>
95 </div>
96 <div class="paging-links layout-content-col span-4">
97 <a href="#" class="prev-page-link">Previous</a>
98 <a href="#" class="next-page-link">Next</a>
99 </div>
100 </div>
101
102
103
104
105<p>Android 3.0 introduced the <em>long press</em> gesture&mdash;that is, a touch that's held in the same
106position for a moment&mdash;as the global gesture to select data. This affects the way you should
107handle multi-select and contextual actions in your apps.</p>
108
109<div class="vspace size-1">&nbsp;</div>
110
111<div class="layout-content-row">
112 <div class="layout-content-col span-6">
113
114<h4>What has changed?</h4>
115<p>In previous versions of Android, the long press gesture was universally used to display contextual
116actions for a given data item in a contextual menu.</p>
117<p>This pattern changed with Android 3.0. The long press gesture is now used to select data, combining
118contextual actions and selection management functions for selected data into a new element called
119the contextual action bar (CAB).</p>
120
121 </div>
122 <div class="layout-content-col span-7">
123
124 <img src="../static/content/selection_context_menu.png">
125 <div class="figure-caption">
126 Traditional use of the long press gesture to show contextual menus.
127 </div>
128
129 </div>
130</div>
131
132<h4>Using the contextual action bar (CAB)</h4>
133<p>The selection CAB is a temporary action bar that overlays your app's current action bar while data
134is selected. It appears after the user long presses on a selectable data item.</p>
135
136<img src="../static/content/selection_cab_big.png">
137
138<div class="vspace size-1">&nbsp;</div>
139
140<div class="layout-content-row">
141 <div class="layout-content-col span-6">
142
143<p>From here the user can:</p>
144<ul>
145<li>Select additional data items by touching them.</li>
146<li>Trigger an action from the CAB that applies to all highlighted data items. The CAB then
147 automatically dismisses itself.</li>
148<li>Dismiss the CAB via the navigation bar's Back button or the CAB's checkmark button. This removes
149 the CAB along with all selection highlights.</li>
150</ul>
151
152 </div>
153 <div class="layout-content-col span-7">
154
155 <img src="../static/content/selection_cab_example.png">
156
157 </div>
158</div>
159
160<div class="layout-content-row">
161 <div class="layout-content-col span-6">
162
163<h4>Selecting CAB actions</h4>
164<p>You can decide which actions and elements appear in the CAB. Use the guidelines in the <a href="actionbar.html">Action Bar
165pattern</a> to decide which items to surface at the top level and which to move to the
166action overflow.</p>
167<h4>Dynamically adjust CAB actions</h4>
168<p>In most cases you need to adjust the actions in the CAB dynamically as the user adds more items to
169the selection. Actions that apply to a single selected data item don't necessarily apply to multiple
170selected data items of the same kind.</p>
171
172 </div>
173 <div class="layout-content-col span-7">
174
175 <img src="../static/content/selection_adjusting_actions.png">
176 <div class="figure-caption">
177 Adjusting actions in the CAB as additional items are selected.
178 </div>
179
180 </div>
181</div>
182
183<h2>Checklist</h2>
184<ul>
185<li>
186<p>Whenever your app supports the selection of multiple data items, make use of the contextual action
187 bar (CAB).</p>
188</li>
189<li>
190<p>Reserve the long press gesture for selection exclusively. Don't use it to display traditional
191 contextual menus.</p>
192</li>
193<li>
194<p>If you don't support multi-selection within a list, long press should do nothing.</p>
195</li>
196<li>
197<p>Plan the actions you want to display inside of a CAB in the same way you would plan the actions
198 inside your app's action bar.</p>
199</li>
200</ul>
201
202
203
204
205 <div class="layout-content-row content-footer">
206 <div class="paging-links layout-content-col span-9">&nbsp;</div>
207 <div class="paging-links layout-content-col span-4">
208 <a href="#" class="prev-page-link">Previous</a>
209 <a href="#" class="next-page-link">Next</a>
210 </div>
211 </div>
212
213 </div>
214
215 </div>
216
217 <div id="page-footer">
218
219 <p id="copyright">
220 Except as noted, this content is licensed under
Roman Nurikc894fb72012-01-10 23:59:20 -0800221 <a href="http://creativecommons.org/licenses/by/2.5/">
Roman Nurik73790462011-12-22 16:18:19 -0800222 Creative Commons Attribution 2.5</a>.<br>
223 For details and restrictions, see the
Roman Nurikc894fb72012-01-10 23:59:20 -0800224 <a href="http://developer.android.com/license.html">Content License</a>.
Roman Nurik73790462011-12-22 16:18:19 -0800225 </p>
226
227 <p>
Roman Nurikc894fb72012-01-10 23:59:20 -0800228 <a href="http://www.android.com/terms.html">Site Terms of Service</a> &ndash;
229 <a href="http://www.android.com/privacy.html">Privacy Policy</a> &ndash;
230 <a href="http://www.android.com/branding.html">Brand Guidelines</a>
Roman Nurik73790462011-12-22 16:18:19 -0800231 </p>
232
233 </div>
234 </div>
235
236 <script src="../static/jquery-1.6.2.min.js"></script>
237 <script>
238 var SITE_ROOT = '../';
239 </script>
240 <script src="../static/default.js"></script>
241
242
243 <script type="text/javascript">
244 var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
245 document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
246 </script>
247 <script type="text/javascript">
248 var pageTracker = _gat._getTracker("UA-5831155-1");
249 pageTracker._trackPageview();
250 </script>
251 </body>
252</html>