blob: 13ae3523de8869d6d932b4aa8a2054856b80050b [file] [log] [blame]
Adam Powell33b97432010-04-20 10:01:14 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.app;
18
Tor Norbyed9273d62013-05-30 15:59:53 -070019import android.annotation.IntDef;
20import android.annotation.NonNull;
21import android.annotation.Nullable;
Adam Powell9ab97872010-10-26 21:47:29 -070022import android.content.Context;
Adam Powelle43340c2014-03-17 19:10:43 -070023import android.content.res.Configuration;
Adam Powell9ab97872010-10-26 21:47:29 -070024import android.content.res.TypedArray;
Adam Powell33b97432010-04-20 10:01:14 -070025import android.graphics.drawable.Drawable;
Adam Powell9ab97872010-10-26 21:47:29 -070026import android.util.AttributeSet;
Adam Powelle43340c2014-03-17 19:10:43 -070027import android.view.ActionMode;
Adam Powell9ab97872010-10-26 21:47:29 -070028import android.view.Gravity;
Adam Powell33b97432010-04-20 10:01:14 -070029import android.view.View;
Adam Powell9ab97872010-10-26 21:47:29 -070030import android.view.ViewDebug;
31import android.view.ViewGroup;
32import android.view.ViewGroup.MarginLayoutParams;
Adam Powell6b336f82010-08-10 20:13:01 -070033import android.view.Window;
Adam Powella4082912010-06-04 18:34:02 -070034import android.widget.SpinnerAdapter;
Adam Powelle43340c2014-03-17 19:10:43 -070035import android.widget.Toolbar;
Adam Powell33b97432010-04-20 10:01:14 -070036
Tor Norbyed9273d62013-05-30 15:59:53 -070037import java.lang.annotation.Retention;
38import java.lang.annotation.RetentionPolicy;
Adam Powelle43340c2014-03-17 19:10:43 -070039import java.util.Map;
Tor Norbyed9273d62013-05-30 15:59:53 -070040
Adam Powell33b97432010-04-20 10:01:14 -070041/**
Adam Powelle43340c2014-03-17 19:10:43 -070042 * A primary toolbar within the activity that may display the activity title, application-level
43 * navigation affordances, and other interactive items.
44 *
Scott Maine797ed62011-09-22 16:17:45 -070045 * <p>Beginning with Android 3.0 (API level 11), the action bar appears at the top of an
46 * activity's window when the activity uses the system's {@link
47 * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default.
48 * You may otherwise add the action bar by calling {@link
49 * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a
50 * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property.
Adam Powelle43340c2014-03-17 19:10:43 -070051 * </p>
52 *
53 * <p>Beginning with Android L (API level 21), the action bar may be represented by any
54 * Toolbar widget within the application layout. The application may signal to the Activity
55 * which Toolbar should be treated as the Activity's action bar. Activities that use this
56 * feature should use one of the supplied <code>.NoActionBar</code> themes, set the
57 * {@link android.R.styleable#Theme_windowActionBar windowActionBar} attribute to <code>false</code>
58 * or otherwise not request the window feature.</p>
59 *
60 * <p>By adjusting the window features requested by the theme and the layouts used for
61 * an Activity's content view, an app can use the standard system action bar on older platform
62 * releases and the newer inline toolbars on newer platform releases. The <code>ActionBar</code>
63 * object obtained from the Activity can be used to control either configuration transparently.</p>
64 *
65 * <p>When using the Holo themes the action bar shows the application icon on
Scott Maine797ed62011-09-22 16:17:45 -070066 * the left, followed by the activity title. If your activity has an options menu, you can make
67 * select items accessible directly from the action bar as "action items". You can also
68 * modify various characteristics of the action bar or remove it completely.</p>
Adam Powelle43340c2014-03-17 19:10:43 -070069 *
70 * <p>When using the Quantum themes (default in API 21 or newer) the navigation button
71 * (formerly "Home") takes over the space previously occupied by the application icon.
72 * Apps wishing to express a stronger branding should use their brand colors heavily
73 * in the action bar and other application chrome or use a {@link #setLogo(int) logo}
74 * in place of their standard title text.</p>
75 *
Scott Main36193d02011-07-12 15:24:01 -070076 * <p>From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link
77 * android.app.Activity#getActionBar getActionBar()}.</p>
Adam Powelle43340c2014-03-17 19:10:43 -070078 *
Scott Maine797ed62011-09-22 16:17:45 -070079 * <p>In some cases, the action bar may be overlayed by another bar that enables contextual actions,
80 * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in
81 * your activity, you can enable an action mode that offers actions specific to the selected
82 * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the
83 * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for
Adam Powelle43340c2014-03-17 19:10:43 -070084 * {@link ActionBar}.</p>
85 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070086 * <div class="special reference">
87 * <h3>Developer Guides</h3>
88 * <p>For information about how to use the action bar, including how to add action items, navigation
89 * modes and more, read the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action
90 * Bar</a> developer guide.</p>
91 * </div>
Adam Powell33b97432010-04-20 10:01:14 -070092 */
93public abstract class ActionBar {
Tor Norbyed9273d62013-05-30 15:59:53 -070094 /** @hide */
95 @Retention(RetentionPolicy.SOURCE)
96 @IntDef({NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS})
97 public @interface NavigationMode {}
98
Adam Powella1700782010-05-13 13:27:35 -070099 /**
Adam Powella4082912010-06-04 18:34:02 -0700100 * Standard navigation mode. Consists of either a logo or icon
Adam Powella1700782010-05-13 13:27:35 -0700101 * and title text with an optional subtitle. Clicking any of these elements
Adam Powellcf035762010-12-06 11:49:45 -0800102 * will dispatch onOptionsItemSelected to the host Activity with
Adam Powella1700782010-05-13 13:27:35 -0700103 * a MenuItem with item ID android.R.id.home.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700104 *
105 * @deprecated Action bar navigation modes are deprecated and not supported by inline
106 * toolbar action bars. Consider using other
107 * <a href="http://developer.android.com/design/patterns/navigation.html">common
108 * navigation patterns</a> instead.
Adam Powella1700782010-05-13 13:27:35 -0700109 */
Adam Powella4082912010-06-04 18:34:02 -0700110 public static final int NAVIGATION_MODE_STANDARD = 0;
Adam Powell33b97432010-04-20 10:01:14 -0700111
112 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700113 * List navigation mode. Instead of static title text this mode
114 * presents a list menu for navigation within the activity.
115 * e.g. this might be presented to the user as a dropdown list.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700116 *
117 * @deprecated Action bar navigation modes are deprecated and not supported by inline
118 * toolbar action bars. Consider using other
119 * <a href="http://developer.android.com/design/patterns/navigation.html">common
120 * navigation patterns</a> instead.
Adam Powell33b97432010-04-20 10:01:14 -0700121 */
Adam Powell9ab97872010-10-26 21:47:29 -0700122 public static final int NAVIGATION_MODE_LIST = 1;
Adam Powell33b97432010-04-20 10:01:14 -0700123
124 /**
125 * Tab navigation mode. Instead of static title text this mode
126 * presents a series of tabs for navigation within the activity.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700127 *
128 * @deprecated Action bar navigation modes are deprecated and not supported by inline
129 * toolbar action bars. Consider using other
130 * <a href="http://developer.android.com/design/patterns/navigation.html">common
131 * navigation patterns</a> instead.
Adam Powell33b97432010-04-20 10:01:14 -0700132 */
133 public static final int NAVIGATION_MODE_TABS = 2;
Adam Powell33b97432010-04-20 10:01:14 -0700134
Tor Norbyed9273d62013-05-30 15:59:53 -0700135 /** @hide */
136 @Retention(RetentionPolicy.SOURCE)
137 @IntDef(flag = true,
138 value = {
139 DISPLAY_USE_LOGO,
140 DISPLAY_SHOW_HOME,
141 DISPLAY_HOME_AS_UP,
142 DISPLAY_SHOW_TITLE,
143 DISPLAY_SHOW_CUSTOM,
144 DISPLAY_TITLE_MULTIPLE_LINES
145 })
146 public @interface DisplayOptions {}
147
Adam Powell33b97432010-04-20 10:01:14 -0700148 /**
149 * Use logo instead of icon if available. This flag will cause appropriate
150 * navigation modes to use a wider logo in place of the standard icon.
Adam Powell9ab97872010-10-26 21:47:29 -0700151 *
152 * @see #setDisplayOptions(int)
153 * @see #setDisplayOptions(int, int)
Adam Powell33b97432010-04-20 10:01:14 -0700154 */
155 public static final int DISPLAY_USE_LOGO = 0x1;
156
157 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700158 * Show 'home' elements in this action bar, leaving more space for other
Adam Powell33b97432010-04-20 10:01:14 -0700159 * navigation elements. This includes logo and icon.
Adam Powell9ab97872010-10-26 21:47:29 -0700160 *
161 * @see #setDisplayOptions(int)
162 * @see #setDisplayOptions(int, int)
Adam Powell33b97432010-04-20 10:01:14 -0700163 */
Adam Powell9ab97872010-10-26 21:47:29 -0700164 public static final int DISPLAY_SHOW_HOME = 0x2;
165
166 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700167 * Display the 'home' element such that it appears as an 'up' affordance.
168 * e.g. show an arrow to the left indicating the action that will be taken.
169 *
170 * Set this flag if selecting the 'home' button in the action bar to return
171 * up by a single level in your UI rather than back to the top level or front page.
172 *
Adam Powellc29f4e52011-07-13 20:40:52 -0700173 * <p>Setting this option will implicitly enable interaction with the home/up
174 * button. See {@link #setHomeButtonEnabled(boolean)}.
175 *
Adam Powell9ab97872010-10-26 21:47:29 -0700176 * @see #setDisplayOptions(int)
177 * @see #setDisplayOptions(int, int)
178 */
179 public static final int DISPLAY_HOME_AS_UP = 0x4;
180
181 /**
182 * Show the activity title and subtitle, if present.
183 *
184 * @see #setTitle(CharSequence)
185 * @see #setTitle(int)
186 * @see #setSubtitle(CharSequence)
187 * @see #setSubtitle(int)
188 * @see #setDisplayOptions(int)
189 * @see #setDisplayOptions(int, int)
190 */
191 public static final int DISPLAY_SHOW_TITLE = 0x8;
192
193 /**
194 * Show the custom view if one has been set.
195 * @see #setCustomView(View)
196 * @see #setDisplayOptions(int)
197 * @see #setDisplayOptions(int, int)
198 */
199 public static final int DISPLAY_SHOW_CUSTOM = 0x10;
200
201 /**
Adam Powell27cba382013-01-22 18:55:20 -0800202 * Allow the title to wrap onto multiple lines if space is available
203 * @hide pending API approval
204 */
205 public static final int DISPLAY_TITLE_MULTIPLE_LINES = 0x20;
206
207 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700208 * Set the action bar into custom navigation mode, supplying a view
209 * for custom navigation.
210 *
211 * Custom navigation views appear between the application icon and
212 * any action buttons and may use any space available there. Common
213 * use cases for custom navigation views might include an auto-suggesting
214 * address bar for a browser or other navigation mechanisms that do not
215 * translate well to provided navigation modes.
216 *
217 * @param view Custom navigation view to place in the ActionBar.
218 */
219 public abstract void setCustomView(View view);
Adam Powell89e06452010-06-23 20:24:52 -0700220
Adam Powell33b97432010-04-20 10:01:14 -0700221 /**
Adam Powella4082912010-06-04 18:34:02 -0700222 * Set the action bar into custom navigation mode, supplying a view
223 * for custom navigation.
Adam Powell33b97432010-04-20 10:01:14 -0700224 *
Adam Powellef704442010-11-16 14:48:22 -0800225 * <p>Custom navigation views appear between the application icon and
Adam Powell33b97432010-04-20 10:01:14 -0700226 * any action buttons and may use any space available there. Common
Adam Powella4082912010-06-04 18:34:02 -0700227 * use cases for custom navigation views might include an auto-suggesting
228 * address bar for a browser or other navigation mechanisms that do not
Adam Powellef704442010-11-16 14:48:22 -0800229 * translate well to provided navigation modes.</p>
230 *
231 * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
232 * the custom view to be displayed.</p>
Adam Powell33b97432010-04-20 10:01:14 -0700233 *
234 * @param view Custom navigation view to place in the ActionBar.
Adam Powell9ab97872010-10-26 21:47:29 -0700235 * @param layoutParams How this custom view should layout in the bar.
Adam Powellef704442010-11-16 14:48:22 -0800236 *
237 * @see #setDisplayOptions(int, int)
Adam Powell33b97432010-04-20 10:01:14 -0700238 */
Adam Powell9ab97872010-10-26 21:47:29 -0700239 public abstract void setCustomView(View view, LayoutParams layoutParams);
240
241 /**
Adam Powell3f476b32011-01-03 19:25:36 -0800242 * Set the action bar into custom navigation mode, supplying a view
243 * for custom navigation.
244 *
245 * <p>Custom navigation views appear between the application icon and
246 * any action buttons and may use any space available there. Common
247 * use cases for custom navigation views might include an auto-suggesting
248 * address bar for a browser or other navigation mechanisms that do not
249 * translate well to provided navigation modes.</p>
250 *
251 * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
252 * the custom view to be displayed.</p>
253 *
254 * @param resId Resource ID of a layout to inflate into the ActionBar.
255 *
256 * @see #setDisplayOptions(int, int)
257 */
258 public abstract void setCustomView(int resId);
259
260 /**
Adam Powell1969b872011-03-22 11:52:48 -0700261 * Set the icon to display in the 'home' section of the action bar.
262 * The action bar will use an icon specified by its style or the
263 * activity icon by default.
264 *
265 * Whether the home section shows an icon or logo is controlled
266 * by the display option {@link #DISPLAY_USE_LOGO}.
267 *
268 * @param resId Resource ID of a drawable to show as an icon.
269 *
270 * @see #setDisplayUseLogoEnabled(boolean)
271 * @see #setDisplayShowHomeEnabled(boolean)
272 */
273 public abstract void setIcon(int resId);
274
275 /**
276 * Set the icon to display in the 'home' section of the action bar.
277 * The action bar will use an icon specified by its style or the
278 * activity icon by default.
279 *
280 * Whether the home section shows an icon or logo is controlled
281 * by the display option {@link #DISPLAY_USE_LOGO}.
282 *
283 * @param icon Drawable to show as an icon.
284 *
285 * @see #setDisplayUseLogoEnabled(boolean)
286 * @see #setDisplayShowHomeEnabled(boolean)
287 */
288 public abstract void setIcon(Drawable icon);
289
290 /**
291 * Set the logo to display in the 'home' section of the action bar.
292 * The action bar will use a logo specified by its style or the
293 * activity logo by default.
294 *
295 * Whether the home section shows an icon or logo is controlled
296 * by the display option {@link #DISPLAY_USE_LOGO}.
297 *
298 * @param resId Resource ID of a drawable to show as a logo.
299 *
300 * @see #setDisplayUseLogoEnabled(boolean)
301 * @see #setDisplayShowHomeEnabled(boolean)
302 */
303 public abstract void setLogo(int resId);
304
305 /**
306 * Set the logo to display in the 'home' section of the action bar.
307 * The action bar will use a logo specified by its style or the
308 * activity logo by default.
309 *
310 * Whether the home section shows an icon or logo is controlled
311 * by the display option {@link #DISPLAY_USE_LOGO}.
312 *
313 * @param logo Drawable to show as a logo.
314 *
315 * @see #setDisplayUseLogoEnabled(boolean)
316 * @see #setDisplayShowHomeEnabled(boolean)
317 */
318 public abstract void setLogo(Drawable logo);
319
320 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700321 * Set the adapter and navigation callback for list navigation mode.
322 *
323 * The supplied adapter will provide views for the expanded list as well as
324 * the currently selected item. (These may be displayed differently.)
325 *
Adam Powell8515ee82010-11-30 14:09:55 -0800326 * The supplied OnNavigationListener will alert the application when the user
Adam Powell9ab97872010-10-26 21:47:29 -0700327 * changes the current list selection.
328 *
329 * @param adapter An adapter that will provide views both to display
330 * the current navigation selection and populate views
331 * within the dropdown navigation menu.
Adam Powell8515ee82010-11-30 14:09:55 -0800332 * @param callback An OnNavigationListener that will receive events when the user
Adam Powell9ab97872010-10-26 21:47:29 -0700333 * selects a navigation item.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700334 *
335 * @deprecated Action bar navigation modes are deprecated and not supported by inline
336 * toolbar action bars. Consider using other
337 * <a href="http://developer.android.com/design/patterns/navigation.html">common
338 * navigation patterns</a> instead.
Adam Powell9ab97872010-10-26 21:47:29 -0700339 */
340 public abstract void setListNavigationCallbacks(SpinnerAdapter adapter,
Adam Powell8515ee82010-11-30 14:09:55 -0800341 OnNavigationListener callback);
Adam Powell9ab97872010-10-26 21:47:29 -0700342
343 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700344 * Set the selected navigation item in list or tabbed navigation modes.
Adam Powell17809772010-07-21 13:25:11 -0700345 *
346 * @param position Position of the item to select.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700347 *
348 * @deprecated Action bar navigation modes are deprecated and not supported by inline
349 * toolbar action bars. Consider using other
350 * <a href="http://developer.android.com/design/patterns/navigation.html">common
351 * navigation patterns</a> instead.
Adam Powell17809772010-07-21 13:25:11 -0700352 */
353 public abstract void setSelectedNavigationItem(int position);
354
355 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700356 * Get the position of the selected navigation item in list or tabbed navigation modes.
357 *
358 * @return Position of the selected item.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700359 *
360 * @deprecated Action bar navigation modes are deprecated and not supported by inline
361 * toolbar action bars. Consider using other
362 * <a href="http://developer.android.com/design/patterns/navigation.html">common
363 * navigation patterns</a> instead.
Adam Powell17809772010-07-21 13:25:11 -0700364 */
Adam Powell9ab97872010-10-26 21:47:29 -0700365 public abstract int getSelectedNavigationIndex();
366
367 /**
368 * Get the number of navigation items present in the current navigation mode.
369 *
370 * @return Number of navigation items.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700371 *
372 * @deprecated Action bar navigation modes are deprecated and not supported by inline
373 * toolbar action bars. Consider using other
374 * <a href="http://developer.android.com/design/patterns/navigation.html">common
375 * navigation patterns</a> instead.
Adam Powell9ab97872010-10-26 21:47:29 -0700376 */
377 public abstract int getNavigationItemCount();
Adam Powell17809772010-07-21 13:25:11 -0700378
379 /**
Adam Powellef704442010-11-16 14:48:22 -0800380 * Set the action bar's title. This will only be displayed if
381 * {@link #DISPLAY_SHOW_TITLE} is set.
Adam Powell0e94b512010-06-29 17:58:20 -0700382 *
383 * @param title Title to set
Adam Powella66c7b02010-07-28 15:28:25 -0700384 *
385 * @see #setTitle(int)
Adam Powellef704442010-11-16 14:48:22 -0800386 * @see #setDisplayOptions(int, int)
Adam Powell0e94b512010-06-29 17:58:20 -0700387 */
388 public abstract void setTitle(CharSequence title);
389
390 /**
Adam Powellef704442010-11-16 14:48:22 -0800391 * Set the action bar's title. This will only be displayed if
392 * {@link #DISPLAY_SHOW_TITLE} is set.
Adam Powella66c7b02010-07-28 15:28:25 -0700393 *
394 * @param resId Resource ID of title string to set
395 *
396 * @see #setTitle(CharSequence)
Adam Powellef704442010-11-16 14:48:22 -0800397 * @see #setDisplayOptions(int, int)
Adam Powella66c7b02010-07-28 15:28:25 -0700398 */
399 public abstract void setTitle(int resId);
400
401 /**
Adam Powellef704442010-11-16 14:48:22 -0800402 * Set the action bar's subtitle. This will only be displayed if
403 * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the
404 * subtitle entirely.
Adam Powell0e94b512010-06-29 17:58:20 -0700405 *
406 * @param subtitle Subtitle to set
Adam Powella66c7b02010-07-28 15:28:25 -0700407 *
408 * @see #setSubtitle(int)
Adam Powellef704442010-11-16 14:48:22 -0800409 * @see #setDisplayOptions(int, int)
Adam Powell0e94b512010-06-29 17:58:20 -0700410 */
411 public abstract void setSubtitle(CharSequence subtitle);
412
413 /**
Adam Powellef704442010-11-16 14:48:22 -0800414 * Set the action bar's subtitle. This will only be displayed if
415 * {@link #DISPLAY_SHOW_TITLE} is set.
Adam Powella66c7b02010-07-28 15:28:25 -0700416 *
417 * @param resId Resource ID of subtitle string to set
418 *
419 * @see #setSubtitle(CharSequence)
Adam Powellef704442010-11-16 14:48:22 -0800420 * @see #setDisplayOptions(int, int)
Adam Powella66c7b02010-07-28 15:28:25 -0700421 */
422 public abstract void setSubtitle(int resId);
423
424 /**
Adam Powella1700782010-05-13 13:27:35 -0700425 * Set display options. This changes all display option bits at once. To change
426 * a limited subset of display options, see {@link #setDisplayOptions(int, int)}.
Adam Powell33b97432010-04-20 10:01:14 -0700427 *
428 * @param options A combination of the bits defined by the DISPLAY_ constants
429 * defined in ActionBar.
430 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700431 public abstract void setDisplayOptions(@DisplayOptions int options);
Adam Powell33b97432010-04-20 10:01:14 -0700432
433 /**
Adam Powella1700782010-05-13 13:27:35 -0700434 * Set selected display options. Only the options specified by mask will be changed.
435 * To change all display option bits at once, see {@link #setDisplayOptions(int)}.
436 *
Adam Powell9ab97872010-10-26 21:47:29 -0700437 * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the
438 * {@link #DISPLAY_SHOW_HOME} option.
Ben Komalo5ad7af62010-11-01 12:04:51 -0700439 * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)
Adam Powell9ab97872010-10-26 21:47:29 -0700440 * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}.
Adam Powella1700782010-05-13 13:27:35 -0700441 *
442 * @param options A combination of the bits defined by the DISPLAY_ constants
443 * defined in ActionBar.
444 * @param mask A bit mask declaring which display options should be changed.
445 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700446 public abstract void setDisplayOptions(@DisplayOptions int options, @DisplayOptions int mask);
Adam Powell3f476b32011-01-03 19:25:36 -0800447
448 /**
449 * Set whether to display the activity logo rather than the activity icon.
450 * A logo is often a wider, more detailed image.
451 *
452 * <p>To set several display options at once, see the setDisplayOptions methods.
453 *
454 * @param useLogo true to use the activity logo, false to use the activity icon.
455 *
456 * @see #setDisplayOptions(int)
457 * @see #setDisplayOptions(int, int)
458 */
459 public abstract void setDisplayUseLogoEnabled(boolean useLogo);
460
461 /**
462 * Set whether to include the application home affordance in the action bar.
463 * Home is presented as either an activity icon or logo.
464 *
465 * <p>To set several display options at once, see the setDisplayOptions methods.
466 *
467 * @param showHome true to show home, false otherwise.
468 *
469 * @see #setDisplayOptions(int)
470 * @see #setDisplayOptions(int, int)
471 */
472 public abstract void setDisplayShowHomeEnabled(boolean showHome);
473
474 /**
475 * Set whether home should be displayed as an "up" affordance.
476 * Set this to true if selecting "home" returns up by a single level in your UI
477 * rather than back to the top level or front page.
478 *
479 * <p>To set several display options at once, see the setDisplayOptions methods.
480 *
481 * @param showHomeAsUp true to show the user that selecting home will return one
482 * level up rather than to the top level of the app.
483 *
484 * @see #setDisplayOptions(int)
485 * @see #setDisplayOptions(int, int)
486 */
487 public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
488
489 /**
490 * Set whether an activity title/subtitle should be displayed.
491 *
492 * <p>To set several display options at once, see the setDisplayOptions methods.
493 *
494 * @param showTitle true to display a title/subtitle if present.
495 *
496 * @see #setDisplayOptions(int)
497 * @see #setDisplayOptions(int, int)
498 */
499 public abstract void setDisplayShowTitleEnabled(boolean showTitle);
500
501 /**
502 * Set whether a custom view should be displayed, if set.
503 *
504 * <p>To set several display options at once, see the setDisplayOptions methods.
505 *
506 * @param showCustom true if the currently set custom view should be displayed, false otherwise.
507 *
508 * @see #setDisplayOptions(int)
509 * @see #setDisplayOptions(int, int)
510 */
511 public abstract void setDisplayShowCustomEnabled(boolean showCustom);
512
Adam Powella1700782010-05-13 13:27:35 -0700513 /**
Adam Powellf88b9152011-09-07 14:54:32 -0700514 * Set the ActionBar's background. This will be used for the primary
515 * action bar.
Adam Powell33b97432010-04-20 10:01:14 -0700516 *
517 * @param d Background drawable
Adam Powellf88b9152011-09-07 14:54:32 -0700518 * @see #setStackedBackgroundDrawable(Drawable)
519 * @see #setSplitBackgroundDrawable(Drawable)
Adam Powell33b97432010-04-20 10:01:14 -0700520 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700521 public abstract void setBackgroundDrawable(@Nullable Drawable d);
Adam Powellef704442010-11-16 14:48:22 -0800522
523 /**
Adam Powellf88b9152011-09-07 14:54:32 -0700524 * Set the ActionBar's stacked background. This will appear
525 * in the second row/stacked bar on some devices and configurations.
526 *
527 * @param d Background drawable for the stacked row
528 */
Adam Powell01453222011-09-07 16:13:36 -0700529 public void setStackedBackgroundDrawable(Drawable d) { }
Adam Powellf88b9152011-09-07 14:54:32 -0700530
531 /**
532 * Set the ActionBar's split background. This will appear in
533 * the split action bar containing menu-provided action buttons
534 * on some devices and configurations.
Scott Maine797ed62011-09-22 16:17:45 -0700535 * <p>You can enable split action bar with {@link android.R.attr#uiOptions}
Adam Powellf88b9152011-09-07 14:54:32 -0700536 *
537 * @param d Background drawable for the split bar
538 */
Adam Powell01453222011-09-07 16:13:36 -0700539 public void setSplitBackgroundDrawable(Drawable d) { }
Adam Powellf88b9152011-09-07 14:54:32 -0700540
541 /**
Adam Powellef704442010-11-16 14:48:22 -0800542 * @return The current custom view.
543 */
544 public abstract View getCustomView();
545
Adam Powell33b97432010-04-20 10:01:14 -0700546 /**
Adam Powella4082912010-06-04 18:34:02 -0700547 * Returns the current ActionBar title in standard mode.
548 * Returns null if {@link #getNavigationMode()} would not return
549 * {@link #NAVIGATION_MODE_STANDARD}.
550 *
551 * @return The current ActionBar title or null.
Adam Powell33b97432010-04-20 10:01:14 -0700552 */
553 public abstract CharSequence getTitle();
554
555 /**
Adam Powella4082912010-06-04 18:34:02 -0700556 * Returns the current ActionBar subtitle in standard mode.
557 * Returns null if {@link #getNavigationMode()} would not return
558 * {@link #NAVIGATION_MODE_STANDARD}.
559 *
560 * @return The current ActionBar subtitle or null.
Adam Powell33b97432010-04-20 10:01:14 -0700561 */
562 public abstract CharSequence getSubtitle();
563
564 /**
Adam Powella4082912010-06-04 18:34:02 -0700565 * Returns the current navigation mode. The result will be one of:
566 * <ul>
567 * <li>{@link #NAVIGATION_MODE_STANDARD}</li>
Adam Powell9ab97872010-10-26 21:47:29 -0700568 * <li>{@link #NAVIGATION_MODE_LIST}</li>
Adam Powella4082912010-06-04 18:34:02 -0700569 * <li>{@link #NAVIGATION_MODE_TABS}</li>
Adam Powella4082912010-06-04 18:34:02 -0700570 * </ul>
571 *
Adam Powell33b97432010-04-20 10:01:14 -0700572 * @return The current navigation mode.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700573 *
574 * @deprecated Action bar navigation modes are deprecated and not supported by inline
575 * toolbar action bars. Consider using other
576 * <a href="http://developer.android.com/design/patterns/navigation.html">common
577 * navigation patterns</a> instead.
Adam Powell33b97432010-04-20 10:01:14 -0700578 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700579 @NavigationMode
Adam Powell33b97432010-04-20 10:01:14 -0700580 public abstract int getNavigationMode();
Adam Powell9ab97872010-10-26 21:47:29 -0700581
582 /**
583 * Set the current navigation mode.
584 *
585 * @param mode The new mode to set.
586 * @see #NAVIGATION_MODE_STANDARD
587 * @see #NAVIGATION_MODE_LIST
588 * @see #NAVIGATION_MODE_TABS
Adam Powellfc35dfd2014-03-17 17:44:59 -0700589 *
590 * @deprecated Action bar navigation modes are deprecated and not supported by inline
591 * toolbar action bars. Consider using other
592 * <a href="http://developer.android.com/design/patterns/navigation.html">common
593 * navigation patterns</a> instead.
Adam Powell9ab97872010-10-26 21:47:29 -0700594 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700595 public abstract void setNavigationMode(@NavigationMode int mode);
Adam Powell9ab97872010-10-26 21:47:29 -0700596
Adam Powell33b97432010-04-20 10:01:14 -0700597 /**
598 * @return The current set of display options.
599 */
600 public abstract int getDisplayOptions();
Adam Powell661c9082010-07-02 10:09:44 -0700601
602 /**
Adam Powell661c9082010-07-02 10:09:44 -0700603 * Create and return a new {@link Tab}.
604 * This tab will not be included in the action bar until it is added.
605 *
Dianne Hackborn2f048832011-06-16 13:31:57 -0700606 * <p>Very often tabs will be used to switch between {@link Fragment}
607 * objects. Here is a typical implementation of such tabs:</p>
608 *
609 * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java
610 * complete}
611 *
Adam Powell661c9082010-07-02 10:09:44 -0700612 * @return A new Tab
613 *
614 * @see #addTab(Tab)
Adam Powellfc35dfd2014-03-17 17:44:59 -0700615 *
616 * @deprecated Action bar navigation modes are deprecated and not supported by inline
617 * toolbar action bars. Consider using other
618 * <a href="http://developer.android.com/design/patterns/navigation.html">common
619 * navigation patterns</a> instead.
Adam Powell661c9082010-07-02 10:09:44 -0700620 */
621 public abstract Tab newTab();
622
623 /**
624 * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
Adam Powell81b89442010-11-02 17:58:56 -0700625 * If this is the first tab to be added it will become the selected tab.
Adam Powell661c9082010-07-02 10:09:44 -0700626 *
627 * @param tab Tab to add
Adam Powellfc35dfd2014-03-17 17:44:59 -0700628 *
629 * @deprecated Action bar navigation modes are deprecated and not supported by inline
630 * toolbar action bars. Consider using other
631 * <a href="http://developer.android.com/design/patterns/navigation.html">common
632 * navigation patterns</a> instead.
Adam Powell661c9082010-07-02 10:09:44 -0700633 */
634 public abstract void addTab(Tab tab);
635
636 /**
Adam Powell81b89442010-11-02 17:58:56 -0700637 * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
638 *
639 * @param tab Tab to add
640 * @param setSelected True if the added tab should become the selected tab.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700641 *
642 * @deprecated Action bar navigation modes are deprecated and not supported by inline
643 * toolbar action bars. Consider using other
644 * <a href="http://developer.android.com/design/patterns/navigation.html">common
645 * navigation patterns</a> instead.
Adam Powell81b89442010-11-02 17:58:56 -0700646 */
647 public abstract void addTab(Tab tab, boolean setSelected);
648
649 /**
Adam Powell2b6230e2010-09-07 17:55:25 -0700650 * Add a tab for use in tabbed navigation mode. The tab will be inserted at
Adam Powell81b89442010-11-02 17:58:56 -0700651 * <code>position</code>. If this is the first tab to be added it will become
652 * the selected tab.
Adam Powell661c9082010-07-02 10:09:44 -0700653 *
654 * @param tab The tab to add
655 * @param position The new position of the tab
Adam Powellfc35dfd2014-03-17 17:44:59 -0700656 *
657 * @deprecated Action bar navigation modes are deprecated and not supported by inline
658 * toolbar action bars. Consider using other
659 * <a href="http://developer.android.com/design/patterns/navigation.html">common
660 * navigation patterns</a> instead.
Adam Powell661c9082010-07-02 10:09:44 -0700661 */
Adam Powell2b6230e2010-09-07 17:55:25 -0700662 public abstract void addTab(Tab tab, int position);
Adam Powell661c9082010-07-02 10:09:44 -0700663
664 /**
Adam Powell81b89442010-11-02 17:58:56 -0700665 * Add a tab for use in tabbed navigation mode. The tab will be insterted at
666 * <code>position</code>.
667 *
668 * @param tab The tab to add
669 * @param position The new position of the tab
670 * @param setSelected True if the added tab should become the selected tab.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700671 *
672 * @deprecated Action bar navigation modes are deprecated and not supported by inline
673 * toolbar action bars. Consider using other
674 * <a href="http://developer.android.com/design/patterns/navigation.html">common
675 * navigation patterns</a> instead.
Adam Powell81b89442010-11-02 17:58:56 -0700676 */
677 public abstract void addTab(Tab tab, int position, boolean setSelected);
678
679 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700680 * Remove a tab from the action bar. If the removed tab was selected it will be deselected
681 * and another tab will be selected if present.
Adam Powell661c9082010-07-02 10:09:44 -0700682 *
683 * @param tab The tab to remove
Adam Powellfc35dfd2014-03-17 17:44:59 -0700684 *
685 * @deprecated Action bar navigation modes are deprecated and not supported by inline
686 * toolbar action bars. Consider using other
687 * <a href="http://developer.android.com/design/patterns/navigation.html">common
688 * navigation patterns</a> instead.
Adam Powell661c9082010-07-02 10:09:44 -0700689 */
690 public abstract void removeTab(Tab tab);
691
692 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700693 * Remove a tab from the action bar. If the removed tab was selected it will be deselected
694 * and another tab will be selected if present.
Adam Powell661c9082010-07-02 10:09:44 -0700695 *
696 * @param position Position of the tab to remove
Adam Powellfc35dfd2014-03-17 17:44:59 -0700697 *
698 * @deprecated Action bar navigation modes are deprecated and not supported by inline
699 * toolbar action bars. Consider using other
700 * <a href="http://developer.android.com/design/patterns/navigation.html">common
701 * navigation patterns</a> instead.
Adam Powell661c9082010-07-02 10:09:44 -0700702 */
703 public abstract void removeTabAt(int position);
704
705 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700706 * Remove all tabs from the action bar and deselect the current tab.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700707 *
708 * @deprecated Action bar navigation modes are deprecated and not supported by inline
709 * toolbar action bars. Consider using other
710 * <a href="http://developer.android.com/design/patterns/navigation.html">common
711 * navigation patterns</a> instead.
Adam Powell9ab97872010-10-26 21:47:29 -0700712 */
713 public abstract void removeAllTabs();
714
715 /**
Adam Powell661c9082010-07-02 10:09:44 -0700716 * Select the specified tab. If it is not a child of this action bar it will be added.
717 *
Adam Powell9ab97872010-10-26 21:47:29 -0700718 * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p>
719 *
Adam Powell661c9082010-07-02 10:09:44 -0700720 * @param tab Tab to select
Adam Powellfc35dfd2014-03-17 17:44:59 -0700721 *
722 * @deprecated Action bar navigation modes are deprecated and not supported by inline
723 * toolbar action bars. Consider using other
724 * <a href="http://developer.android.com/design/patterns/navigation.html">common
725 * navigation patterns</a> instead.
Adam Powell661c9082010-07-02 10:09:44 -0700726 */
727 public abstract void selectTab(Tab tab);
728
729 /**
Adam Powell2b6230e2010-09-07 17:55:25 -0700730 * Returns the currently selected tab if in tabbed navigation mode and there is at least
731 * one tab present.
732 *
733 * @return The currently selected tab or null
Adam Powellfc35dfd2014-03-17 17:44:59 -0700734 *
735 * @deprecated Action bar navigation modes are deprecated and not supported by inline
736 * toolbar action bars. Consider using other
737 * <a href="http://developer.android.com/design/patterns/navigation.html">common
738 * navigation patterns</a> instead.
Adam Powell2b6230e2010-09-07 17:55:25 -0700739 */
740 public abstract Tab getSelectedTab();
741
742 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700743 * Returns the tab at the specified index.
744 *
745 * @param index Index value in the range 0-get
746 * @return
Adam Powellfc35dfd2014-03-17 17:44:59 -0700747 *
748 * @deprecated Action bar navigation modes are deprecated and not supported by inline
749 * toolbar action bars. Consider using other
750 * <a href="http://developer.android.com/design/patterns/navigation.html">common
751 * navigation patterns</a> instead.
Adam Powell9ab97872010-10-26 21:47:29 -0700752 */
753 public abstract Tab getTabAt(int index);
754
755 /**
Adam Powell0c24a552010-11-03 16:44:11 -0700756 * Returns the number of tabs currently registered with the action bar.
757 * @return Tab count
Adam Powellfc35dfd2014-03-17 17:44:59 -0700758 *
759 * @deprecated Action bar navigation modes are deprecated and not supported by inline
760 * toolbar action bars. Consider using other
761 * <a href="http://developer.android.com/design/patterns/navigation.html">common
762 * navigation patterns</a> instead.
Adam Powell0c24a552010-11-03 16:44:11 -0700763 */
764 public abstract int getTabCount();
765
766 /**
Adam Powell6b336f82010-08-10 20:13:01 -0700767 * Retrieve the current height of the ActionBar.
768 *
769 * @return The ActionBar's height
770 */
771 public abstract int getHeight();
772
773 /**
774 * Show the ActionBar if it is not currently showing.
775 * If the window hosting the ActionBar does not have the feature
776 * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
777 * content to fit the new space available.
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700778 *
779 * <p>If you are hiding the ActionBar through
780 * {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN},
781 * you should not call this function directly.
Adam Powell6b336f82010-08-10 20:13:01 -0700782 */
783 public abstract void show();
784
785 /**
Scott Maine797ed62011-09-22 16:17:45 -0700786 * Hide the ActionBar if it is currently showing.
Adam Powell6b336f82010-08-10 20:13:01 -0700787 * If the window hosting the ActionBar does not have the feature
788 * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
789 * content to fit the new space available.
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700790 *
791 * <p>Instead of calling this function directly, you can also cause an
792 * ActionBar using the overlay feature to hide through
793 * {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN}.
794 * Hiding the ActionBar through this system UI flag allows you to more
795 * seamlessly hide it in conjunction with other screen decorations.
Adam Powell6b336f82010-08-10 20:13:01 -0700796 */
797 public abstract void hide();
798
799 /**
800 * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise.
801 */
802 public abstract boolean isShowing();
803
804 /**
Adam Powell8515ee82010-11-30 14:09:55 -0800805 * Add a listener that will respond to menu visibility change events.
806 *
807 * @param listener The new listener to add
Adam Powell89e06452010-06-23 20:24:52 -0700808 */
Adam Powell8515ee82010-11-30 14:09:55 -0800809 public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener);
810
811 /**
812 * Remove a menu visibility listener. This listener will no longer receive menu
813 * visibility change events.
814 *
815 * @param listener A listener to remove that was previously added
816 */
817 public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener);
818
819 /**
Adam Powellc29f4e52011-07-13 20:40:52 -0700820 * Enable or disable the "home" button in the corner of the action bar. (Note that this
821 * is the application home/up affordance on the action bar, not the systemwide home
822 * button.)
823 *
824 * <p>This defaults to true for packages targeting &lt; API 14. For packages targeting
825 * API 14 or greater, the application should call this method to enable interaction
826 * with the home/up affordance.
827 *
828 * <p>Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable
829 * the home button.
830 *
831 * @param enabled true to enable the home button, false to disable the home button.
832 */
Adam Powell88ab6972011-07-28 11:25:01 -0700833 public void setHomeButtonEnabled(boolean enabled) { }
834
835 /**
836 * Returns a {@link Context} with an appropriate theme for creating views that
837 * will appear in the action bar. If you are inflating or instantiating custom views
838 * that will appear in an action bar, you should use the Context returned by this method.
839 * (This includes adapters used for list navigation mode.)
840 * This will ensure that views contrast properly against the action bar.
841 *
842 * @return A themed Context for creating views
843 */
844 public Context getThemedContext() { return null; }
Adam Powellc29f4e52011-07-13 20:40:52 -0700845
846 /**
Adam Powell27cba382013-01-22 18:55:20 -0800847 * Returns true if the Title field has been truncated during layout for lack
848 * of available space.
849 *
850 * @return true if the Title field has been truncated
851 * @hide pending API approval
852 */
853 public boolean isTitleTruncated() { return false; }
854
855 /**
Adam Powelle0e2f4f2013-04-05 16:27:35 -0700856 * Set an alternate drawable to display next to the icon/logo/title
857 * when {@link #DISPLAY_HOME_AS_UP} is enabled. This can be useful if you are using
858 * this mode to display an alternate selection for up navigation, such as a sliding drawer.
859 *
860 * <p>If you pass <code>null</code> to this method, the default drawable from the theme
861 * will be used.</p>
862 *
863 * <p>If you implement alternate or intermediate behavior around Up, you should also
864 * call {@link #setHomeActionContentDescription(int) setHomeActionContentDescription()}
865 * to provide a correct description of the action for accessibility support.</p>
866 *
867 * @param indicator A drawable to use for the up indicator, or null to use the theme's default
868 *
869 * @see #setDisplayOptions(int, int)
870 * @see #setDisplayHomeAsUpEnabled(boolean)
871 * @see #setHomeActionContentDescription(int)
872 */
873 public void setHomeAsUpIndicator(Drawable indicator) { }
874
875 /**
876 * Set an alternate drawable to display next to the icon/logo/title
877 * when {@link #DISPLAY_HOME_AS_UP} is enabled. This can be useful if you are using
878 * this mode to display an alternate selection for up navigation, such as a sliding drawer.
879 *
880 * <p>If you pass <code>0</code> to this method, the default drawable from the theme
881 * will be used.</p>
882 *
883 * <p>If you implement alternate or intermediate behavior around Up, you should also
884 * call {@link #setHomeActionContentDescription(int) setHomeActionContentDescription()}
885 * to provide a correct description of the action for accessibility support.</p>
886 *
887 * @param resId Resource ID of a drawable to use for the up indicator, or null
888 * to use the theme's default
889 *
890 * @see #setDisplayOptions(int, int)
891 * @see #setDisplayHomeAsUpEnabled(boolean)
892 * @see #setHomeActionContentDescription(int)
893 */
894 public void setHomeAsUpIndicator(int resId) { }
895
896 /**
897 * Set an alternate description for the Home/Up action, when enabled.
898 *
899 * <p>This description is commonly used for accessibility/screen readers when
900 * the Home action is enabled. (See {@link #setDisplayHomeAsUpEnabled(boolean)}.)
901 * Examples of this are, "Navigate Home" or "Navigate Up" depending on the
902 * {@link #DISPLAY_HOME_AS_UP} display option. If you have changed the home-as-up
903 * indicator using {@link #setHomeAsUpIndicator(int)} to indicate more specific
904 * functionality such as a sliding drawer, you should also set this to accurately
905 * describe the action.</p>
906 *
907 * <p>Setting this to <code>null</code> will use the system default description.</p>
908 *
909 * @param description New description for the Home action when enabled
910 * @see #setHomeAsUpIndicator(int)
911 * @see #setHomeAsUpIndicator(android.graphics.drawable.Drawable)
912 */
913 public void setHomeActionContentDescription(CharSequence description) { }
914
915 /**
916 * Set an alternate description for the Home/Up action, when enabled.
917 *
918 * <p>This description is commonly used for accessibility/screen readers when
919 * the Home action is enabled. (See {@link #setDisplayHomeAsUpEnabled(boolean)}.)
920 * Examples of this are, "Navigate Home" or "Navigate Up" depending on the
921 * {@link #DISPLAY_HOME_AS_UP} display option. If you have changed the home-as-up
922 * indicator using {@link #setHomeAsUpIndicator(int)} to indicate more specific
923 * functionality such as a sliding drawer, you should also set this to accurately
924 * describe the action.</p>
925 *
926 * <p>Setting this to <code>0</code> will use the system default description.</p>
927 *
928 * @param resId Resource ID of a string to use as the new description
929 * for the Home action when enabled
930 * @see #setHomeAsUpIndicator(int)
931 * @see #setHomeAsUpIndicator(android.graphics.drawable.Drawable)
932 */
933 public void setHomeActionContentDescription(int resId) { }
934
Adam Powelle43340c2014-03-17 19:10:43 -0700935 /** @hide */
936 public void setDefaultDisplayHomeAsUpEnabled(boolean enabled) {
937 }
938
939 /** @hide */
940 public void setShowHideAnimationEnabled(boolean enabled) {
941 }
942
943 /** @hide */
944 public void onConfigurationChanged(Configuration config) {
945 }
946
947 /** @hide */
948 public void dispatchMenuVisibilityChanged(boolean visible) {
949 }
950
951 /** @hide */
952 public void captureSharedElements(Map<String, View> sharedElements) {
953 }
954
955 /** @hide */
956 public ActionMode startActionMode(ActionMode.Callback callback) {
957 return null;
958 }
959
Adam Powelle0e2f4f2013-04-05 16:27:35 -0700960 /**
Adam Powell8515ee82010-11-30 14:09:55 -0800961 * Listener interface for ActionBar navigation events.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700962 *
963 * @deprecated Action bar navigation modes are deprecated and not supported by inline
964 * toolbar action bars. Consider using other
965 * <a href="http://developer.android.com/design/patterns/navigation.html">common
966 * navigation patterns</a> instead.
Adam Powell8515ee82010-11-30 14:09:55 -0800967 */
968 public interface OnNavigationListener {
Adam Powell33b97432010-04-20 10:01:14 -0700969 /**
Adam Powella4082912010-06-04 18:34:02 -0700970 * This method is called whenever a navigation item in your action bar
971 * is selected.
972 *
973 * @param itemPosition Position of the item clicked.
974 * @param itemId ID of the item clicked.
975 * @return True if the event was handled, false otherwise.
976 */
977 public boolean onNavigationItemSelected(int itemPosition, long itemId);
Adam Powell33b97432010-04-20 10:01:14 -0700978 }
Adam Powell661c9082010-07-02 10:09:44 -0700979
980 /**
Adam Powell8515ee82010-11-30 14:09:55 -0800981 * Listener for receiving events when action bar menus are shown or hidden.
982 */
983 public interface OnMenuVisibilityListener {
984 /**
985 * Called when an action bar menu is shown or hidden. Applications may want to use
986 * this to tune auto-hiding behavior for the action bar or pause/resume video playback,
987 * gameplay, or other activity within the main content area.
988 *
989 * @param isVisible True if an action bar menu is now visible, false if no action bar
990 * menus are visible.
991 */
992 public void onMenuVisibilityChanged(boolean isVisible);
993 }
994
995 /**
Adam Powell661c9082010-07-02 10:09:44 -0700996 * A tab in the action bar.
997 *
998 * <p>Tabs manage the hiding and showing of {@link Fragment}s.
Adam Powellfc35dfd2014-03-17 17:44:59 -0700999 *
1000 * @deprecated Action bar navigation modes are deprecated and not supported by inline
1001 * toolbar action bars. Consider using other
1002 * <a href="http://developer.android.com/design/patterns/navigation.html">common
1003 * navigation patterns</a> instead.
Adam Powell661c9082010-07-02 10:09:44 -07001004 */
1005 public static abstract class Tab {
1006 /**
1007 * An invalid position for a tab.
1008 *
1009 * @see #getPosition()
1010 */
1011 public static final int INVALID_POSITION = -1;
1012
1013 /**
1014 * Return the current position of this tab in the action bar.
1015 *
1016 * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in
1017 * the action bar.
1018 */
1019 public abstract int getPosition();
1020
1021 /**
1022 * Return the icon associated with this tab.
1023 *
1024 * @return The tab's icon
1025 */
1026 public abstract Drawable getIcon();
1027
1028 /**
1029 * Return the text of this tab.
1030 *
1031 * @return The tab's text
1032 */
1033 public abstract CharSequence getText();
1034
1035 /**
1036 * Set the icon displayed on this tab.
1037 *
1038 * @param icon The drawable to use as an icon
Adam Powell9ab97872010-10-26 21:47:29 -07001039 * @return The current instance for call chaining
Adam Powell661c9082010-07-02 10:09:44 -07001040 */
Adam Powell9ab97872010-10-26 21:47:29 -07001041 public abstract Tab setIcon(Drawable icon);
Adam Powell661c9082010-07-02 10:09:44 -07001042
1043 /**
Adam Powell32555f32010-11-17 13:49:22 -08001044 * Set the icon displayed on this tab.
1045 *
1046 * @param resId Resource ID referring to the drawable to use as an icon
1047 * @return The current instance for call chaining
1048 */
1049 public abstract Tab setIcon(int resId);
1050
1051 /**
Adam Powell661c9082010-07-02 10:09:44 -07001052 * Set the text displayed on this tab. Text may be truncated if there is not
1053 * room to display the entire string.
1054 *
1055 * @param text The text to display
Adam Powell9ab97872010-10-26 21:47:29 -07001056 * @return The current instance for call chaining
Adam Powell661c9082010-07-02 10:09:44 -07001057 */
Adam Powell9ab97872010-10-26 21:47:29 -07001058 public abstract Tab setText(CharSequence text);
Adam Powell661c9082010-07-02 10:09:44 -07001059
1060 /**
Adam Powell32555f32010-11-17 13:49:22 -08001061 * Set the text displayed on this tab. Text may be truncated if there is not
1062 * room to display the entire string.
1063 *
1064 * @param resId A resource ID referring to the text that should be displayed
1065 * @return The current instance for call chaining
1066 */
1067 public abstract Tab setText(int resId);
1068
1069 /**
Adam Powell2b6230e2010-09-07 17:55:25 -07001070 * Set a custom view to be used for this tab. This overrides values set by
1071 * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
Adam Powell661c9082010-07-02 10:09:44 -07001072 *
Adam Powell2b6230e2010-09-07 17:55:25 -07001073 * @param view Custom view to be used as a tab.
Adam Powell9ab97872010-10-26 21:47:29 -07001074 * @return The current instance for call chaining
Adam Powell661c9082010-07-02 10:09:44 -07001075 */
Adam Powell9ab97872010-10-26 21:47:29 -07001076 public abstract Tab setCustomView(View view);
Adam Powell661c9082010-07-02 10:09:44 -07001077
1078 /**
Adam Powell32555f32010-11-17 13:49:22 -08001079 * Set a custom view to be used for this tab. This overrides values set by
1080 * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
1081 *
1082 * @param layoutResId A layout resource to inflate and use as a custom tab view
1083 * @return The current instance for call chaining
1084 */
1085 public abstract Tab setCustomView(int layoutResId);
1086
1087 /**
Adam Powell2b6230e2010-09-07 17:55:25 -07001088 * Retrieve a previously set custom view for this tab.
Adam Powell661c9082010-07-02 10:09:44 -07001089 *
Adam Powell2b6230e2010-09-07 17:55:25 -07001090 * @return The custom view set by {@link #setCustomView(View)}.
Adam Powell661c9082010-07-02 10:09:44 -07001091 */
Adam Powell2b6230e2010-09-07 17:55:25 -07001092 public abstract View getCustomView();
1093
1094 /**
1095 * Give this Tab an arbitrary object to hold for later use.
1096 *
1097 * @param obj Object to store
Adam Powell9ab97872010-10-26 21:47:29 -07001098 * @return The current instance for call chaining
Adam Powell2b6230e2010-09-07 17:55:25 -07001099 */
Adam Powell9ab97872010-10-26 21:47:29 -07001100 public abstract Tab setTag(Object obj);
Adam Powell2b6230e2010-09-07 17:55:25 -07001101
1102 /**
1103 * @return This Tab's tag object.
1104 */
1105 public abstract Object getTag();
1106
1107 /**
1108 * Set the {@link TabListener} that will handle switching to and from this tab.
1109 * All tabs must have a TabListener set before being added to the ActionBar.
1110 *
1111 * @param listener Listener to handle tab selection events
Adam Powell9ab97872010-10-26 21:47:29 -07001112 * @return The current instance for call chaining
Adam Powell2b6230e2010-09-07 17:55:25 -07001113 */
Adam Powell9ab97872010-10-26 21:47:29 -07001114 public abstract Tab setTabListener(TabListener listener);
Adam Powell661c9082010-07-02 10:09:44 -07001115
1116 /**
1117 * Select this tab. Only valid if the tab has been added to the action bar.
1118 */
1119 public abstract void select();
Adam Powell94e56ef2011-09-06 21:22:22 -07001120
1121 /**
1122 * Set a description of this tab's content for use in accessibility support.
1123 * If no content description is provided the title will be used.
1124 *
1125 * @param resId A resource ID referring to the description text
1126 * @return The current instance for call chaining
1127 * @see #setContentDescription(CharSequence)
1128 * @see #getContentDescription()
1129 */
1130 public abstract Tab setContentDescription(int resId);
1131
1132 /**
1133 * Set a description of this tab's content for use in accessibility support.
1134 * If no content description is provided the title will be used.
1135 *
1136 * @param contentDesc Description of this tab's content
1137 * @return The current instance for call chaining
1138 * @see #setContentDescription(int)
1139 * @see #getContentDescription()
1140 */
1141 public abstract Tab setContentDescription(CharSequence contentDesc);
1142
1143 /**
1144 * Gets a brief description of this tab's content for use in accessibility support.
1145 *
1146 * @return Description of this tab's content
1147 * @see #setContentDescription(CharSequence)
1148 * @see #setContentDescription(int)
1149 */
1150 public abstract CharSequence getContentDescription();
Adam Powell661c9082010-07-02 10:09:44 -07001151 }
Adam Powell2b6230e2010-09-07 17:55:25 -07001152
1153 /**
1154 * Callback interface invoked when a tab is focused, unfocused, added, or removed.
Adam Powellfc35dfd2014-03-17 17:44:59 -07001155 *
1156 * @deprecated Action bar navigation modes are deprecated and not supported by inline
1157 * toolbar action bars. Consider using other
1158 * <a href="http://developer.android.com/design/patterns/navigation.html">common
1159 * navigation patterns</a> instead.
Adam Powell2b6230e2010-09-07 17:55:25 -07001160 */
1161 public interface TabListener {
1162 /**
1163 * Called when a tab enters the selected state.
1164 *
1165 * @param tab The tab that was selected
1166 * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
1167 * during a tab switch. The previous tab's unselect and this tab's select will be
Adam Powell0c24a552010-11-03 16:44:11 -07001168 * executed in a single transaction. This FragmentTransaction does not support
1169 * being added to the back stack.
Adam Powell2b6230e2010-09-07 17:55:25 -07001170 */
1171 public void onTabSelected(Tab tab, FragmentTransaction ft);
1172
1173 /**
1174 * Called when a tab exits the selected state.
1175 *
1176 * @param tab The tab that was unselected
1177 * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
1178 * during a tab switch. This tab's unselect and the newly selected tab's select
Adam Powell0c24a552010-11-03 16:44:11 -07001179 * will be executed in a single transaction. This FragmentTransaction does not
1180 * support being added to the back stack.
Adam Powell2b6230e2010-09-07 17:55:25 -07001181 */
1182 public void onTabUnselected(Tab tab, FragmentTransaction ft);
Adam Powell7f9b9052010-10-19 16:56:07 -07001183
1184 /**
1185 * Called when a tab that is already selected is chosen again by the user.
1186 * Some applications may use this action to return to the top level of a category.
1187 *
1188 * @param tab The tab that was reselected.
1189 * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
Adam Powell0c24a552010-11-03 16:44:11 -07001190 * once this method returns. This FragmentTransaction does not support
1191 * being added to the back stack.
Adam Powell7f9b9052010-10-19 16:56:07 -07001192 */
1193 public void onTabReselected(Tab tab, FragmentTransaction ft);
Adam Powell2b6230e2010-09-07 17:55:25 -07001194 }
Adam Powell9ab97872010-10-26 21:47:29 -07001195
1196 /**
1197 * Per-child layout information associated with action bar custom views.
1198 *
1199 * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity
1200 */
Adam Powelle43340c2014-03-17 19:10:43 -07001201 public static class LayoutParams extends ViewGroup.MarginLayoutParams {
Adam Powell9ab97872010-10-26 21:47:29 -07001202 /**
1203 * Gravity for the view associated with these LayoutParams.
1204 *
1205 * @see android.view.Gravity
1206 */
1207 @ViewDebug.ExportedProperty(category = "layout", mapping = {
Adam Powelle43340c2014-03-17 19:10:43 -07001208 @ViewDebug.IntToString(from = -1, to = "NONE"),
1209 @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"),
1210 @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"),
1211 @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"),
1212 @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"),
1213 @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"),
1214 @ViewDebug.IntToString(from = Gravity.START, to = "START"),
1215 @ViewDebug.IntToString(from = Gravity.END, to = "END"),
1216 @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"),
1217 @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"),
1218 @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),
1219 @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"),
1220 @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"),
1221 @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL")
Adam Powell9ab97872010-10-26 21:47:29 -07001222 })
Fabrice Di Megliocf1ba022012-06-25 15:49:11 -07001223 public int gravity = Gravity.NO_GRAVITY;
Adam Powell9ab97872010-10-26 21:47:29 -07001224
Tor Norbyed9273d62013-05-30 15:59:53 -07001225 public LayoutParams(@NonNull Context c, AttributeSet attrs) {
Adam Powell9ab97872010-10-26 21:47:29 -07001226 super(c, attrs);
Adam Powell9ab97872010-10-26 21:47:29 -07001227 }
1228
1229 public LayoutParams(int width, int height) {
1230 super(width, height);
Adam Powell9ab97872010-10-26 21:47:29 -07001231 }
1232
1233 public LayoutParams(int width, int height, int gravity) {
1234 super(width, height);
Adam Powell9ab97872010-10-26 21:47:29 -07001235 }
1236
1237 public LayoutParams(int gravity) {
1238 this(WRAP_CONTENT, MATCH_PARENT, gravity);
1239 }
1240
1241 public LayoutParams(LayoutParams source) {
1242 super(source);
Adam Powell9ab97872010-10-26 21:47:29 -07001243 }
1244
1245 public LayoutParams(ViewGroup.LayoutParams source) {
1246 super(source);
1247 }
Adam Powelle43340c2014-03-17 19:10:43 -07001248
1249 public LayoutParams(MarginLayoutParams source) {
1250 super(source);
1251 }
Adam Powell9ab97872010-10-26 21:47:29 -07001252 }
Adam Powell33b97432010-04-20 10:01:14 -07001253}