blob: e3ee90ed73ad34a32af93d35c2a127bc5dc1e36d [file] [log] [blame]
Roman Nurikb99ae732012-03-06 12:26:15 -08001page.title=Selection
2@jd:body
3
4<p>Android 3.0 introduced the <em>long press</em> gesture&mdash;that is, a touch that's held in the same
5position for a moment&mdash;as the global gesture to select data. This affects the way you should
6handle multi-select and contextual actions in your apps.</p>
7
8<div class="vspace size-1">&nbsp;</div>
9
10<div class="layout-content-row">
11 <div class="layout-content-col span-6">
12
13<h4>What has changed?</h4>
14<p>In previous versions of Android, the long press gesture was universally used to display contextual
15actions for a given data item in a contextual menu.</p>
16<p>This pattern changed with Android 3.0. The long press gesture is now used to select data, combining
17contextual actions and selection management functions for selected data into a new element called
18the contextual action bar (CAB).</p>
19
20 </div>
21 <div class="layout-content-col span-7">
22
23 <img src="{@docRoot}design/media/selection_context_menu.png">
24 <div class="figure-caption">
25 Traditional use of the long press gesture to show contextual menus.
26 </div>
27
28 </div>
29</div>
30
31<h4>Using the contextual action bar (CAB)</h4>
32<p>The selection CAB is a temporary action bar that overlays your app's current action bar while data
33is selected. It appears after the user long presses on a selectable data item.</p>
34
35<img src="{@docRoot}design/media/selection_cab_big.png">
36
37<div class="vspace size-1">&nbsp;</div>
38
39<div class="layout-content-row">
40 <div class="layout-content-col span-6">
41
42<p>From here the user can:</p>
43<ul>
44<li>Select additional data items by touching them.</li>
45<li>Trigger an action from the CAB that applies to all highlighted data items. The CAB then
46 automatically dismisses itself.</li>
47<li>Dismiss the CAB via the navigation bar's Back button or the CAB's checkmark button. This removes
48 the CAB along with all selection highlights.</li>
49</ul>
50
51 </div>
52 <div class="layout-content-col span-7">
53
54 <img src="{@docRoot}design/media/selection_cab_example.png">
55
56 </div>
57</div>
58
59<div class="layout-content-row">
60 <div class="layout-content-col span-6">
61
62<h4>Selecting CAB actions</h4>
63<p>You can decide which actions and elements appear in the CAB. Use the guidelines in the <a href="actionbar.html">Action Bar
64pattern</a> to decide which items to surface at the top level and which to move to the
65action overflow.</p>
66<h4>Dynamically adjust CAB actions</h4>
67<p>In most cases you need to adjust the actions in the CAB dynamically as the user adds more items to
68the selection. Actions that apply to a single selected data item don't necessarily apply to multiple
69selected data items of the same kind.</p>
70
71 </div>
72 <div class="layout-content-col span-7">
73
74 <img src="{@docRoot}design/media/selection_adjusting_actions.png">
75 <div class="figure-caption">
76 Adjusting actions in the CAB as additional items are selected.
77 </div>
78
79 </div>
80</div>
81
82<h2 id="checklist">Checklist</h2>
83
84<ul>
85<li>
86<p>Whenever your app supports the selection of multiple data items, make use of the contextual action
87 bar (CAB).</p>
88</li>
89<li>
90<p>Reserve the long press gesture for selection exclusively. Don't use it to display traditional
91 contextual menus.</p>
92</li>
93<li>
94<p>If you don't support multi-selection within a list, long press should do nothing.</p>
95</li>
96<li>
97<p>Plan the actions you want to display inside of a CAB in the same way you would plan the actions
98 inside your app's action bar.</p>
99</li>
100</ul>