blob: fbe898771856fdf0e7aa5670379d237311bdede8 [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;
23import android.content.res.TypedArray;
Adam Powell33b97432010-04-20 10:01:14 -070024import android.graphics.drawable.Drawable;
Adam Powell9ab97872010-10-26 21:47:29 -070025import android.util.AttributeSet;
26import android.view.Gravity;
Adam Powell33b97432010-04-20 10:01:14 -070027import android.view.View;
Adam Powell9ab97872010-10-26 21:47:29 -070028import android.view.ViewDebug;
29import android.view.ViewGroup;
30import android.view.ViewGroup.MarginLayoutParams;
Adam Powell6b336f82010-08-10 20:13:01 -070031import android.view.Window;
Adam Powella4082912010-06-04 18:34:02 -070032import android.widget.SpinnerAdapter;
Adam Powell33b97432010-04-20 10:01:14 -070033
Tor Norbyed9273d62013-05-30 15:59:53 -070034import java.lang.annotation.Retention;
35import java.lang.annotation.RetentionPolicy;
36
Adam Powell33b97432010-04-20 10:01:14 -070037/**
Scott Maine797ed62011-09-22 16:17:45 -070038 * A window feature at the top of the activity that may display the activity title, navigation
39 * modes, and other interactive items.
40 * <p>Beginning with Android 3.0 (API level 11), the action bar appears at the top of an
41 * activity's window when the activity uses the system's {@link
42 * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default.
43 * You may otherwise add the action bar by calling {@link
44 * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a
45 * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property.
46 * <p>By default, the action bar shows the application icon on
47 * the left, followed by the activity title. If your activity has an options menu, you can make
48 * select items accessible directly from the action bar as "action items". You can also
49 * modify various characteristics of the action bar or remove it completely.</p>
Scott Main36193d02011-07-12 15:24:01 -070050 * <p>From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link
51 * android.app.Activity#getActionBar getActionBar()}.</p>
Scott Maine797ed62011-09-22 16:17:45 -070052 * <p>In some cases, the action bar may be overlayed by another bar that enables contextual actions,
53 * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in
54 * your activity, you can enable an action mode that offers actions specific to the selected
55 * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the
56 * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for
57 * {@link ActionBar}.
Joe Fernandezb54e7a32011-10-03 15:09:50 -070058 * <div class="special reference">
59 * <h3>Developer Guides</h3>
60 * <p>For information about how to use the action bar, including how to add action items, navigation
61 * modes and more, read the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action
62 * Bar</a> developer guide.</p>
63 * </div>
Adam Powell33b97432010-04-20 10:01:14 -070064 */
65public abstract class ActionBar {
Tor Norbyed9273d62013-05-30 15:59:53 -070066 /** @hide */
67 @Retention(RetentionPolicy.SOURCE)
68 @IntDef({NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS})
69 public @interface NavigationMode {}
70
Adam Powella1700782010-05-13 13:27:35 -070071 /**
Adam Powella4082912010-06-04 18:34:02 -070072 * Standard navigation mode. Consists of either a logo or icon
Adam Powella1700782010-05-13 13:27:35 -070073 * and title text with an optional subtitle. Clicking any of these elements
Adam Powellcf035762010-12-06 11:49:45 -080074 * will dispatch onOptionsItemSelected to the host Activity with
Adam Powella1700782010-05-13 13:27:35 -070075 * a MenuItem with item ID android.R.id.home.
76 */
Adam Powella4082912010-06-04 18:34:02 -070077 public static final int NAVIGATION_MODE_STANDARD = 0;
Adam Powell33b97432010-04-20 10:01:14 -070078
79 /**
Adam Powell9ab97872010-10-26 21:47:29 -070080 * List navigation mode. Instead of static title text this mode
81 * presents a list menu for navigation within the activity.
82 * e.g. this might be presented to the user as a dropdown list.
Adam Powell33b97432010-04-20 10:01:14 -070083 */
Adam Powell9ab97872010-10-26 21:47:29 -070084 public static final int NAVIGATION_MODE_LIST = 1;
Adam Powell33b97432010-04-20 10:01:14 -070085
86 /**
87 * Tab navigation mode. Instead of static title text this mode
88 * presents a series of tabs for navigation within the activity.
89 */
90 public static final int NAVIGATION_MODE_TABS = 2;
Adam Powell33b97432010-04-20 10:01:14 -070091
Tor Norbyed9273d62013-05-30 15:59:53 -070092 /** @hide */
93 @Retention(RetentionPolicy.SOURCE)
94 @IntDef(flag = true,
95 value = {
96 DISPLAY_USE_LOGO,
97 DISPLAY_SHOW_HOME,
98 DISPLAY_HOME_AS_UP,
99 DISPLAY_SHOW_TITLE,
100 DISPLAY_SHOW_CUSTOM,
101 DISPLAY_TITLE_MULTIPLE_LINES
102 })
103 public @interface DisplayOptions {}
104
Adam Powell33b97432010-04-20 10:01:14 -0700105 /**
106 * Use logo instead of icon if available. This flag will cause appropriate
107 * navigation modes to use a wider logo in place of the standard icon.
Adam Powell9ab97872010-10-26 21:47:29 -0700108 *
109 * @see #setDisplayOptions(int)
110 * @see #setDisplayOptions(int, int)
Adam Powell33b97432010-04-20 10:01:14 -0700111 */
112 public static final int DISPLAY_USE_LOGO = 0x1;
113
114 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700115 * Show 'home' elements in this action bar, leaving more space for other
Adam Powell33b97432010-04-20 10:01:14 -0700116 * navigation elements. This includes logo and icon.
Adam Powell9ab97872010-10-26 21:47:29 -0700117 *
118 * @see #setDisplayOptions(int)
119 * @see #setDisplayOptions(int, int)
Adam Powell33b97432010-04-20 10:01:14 -0700120 */
Adam Powell9ab97872010-10-26 21:47:29 -0700121 public static final int DISPLAY_SHOW_HOME = 0x2;
122
123 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700124 * Display the 'home' element such that it appears as an 'up' affordance.
125 * e.g. show an arrow to the left indicating the action that will be taken.
126 *
127 * Set this flag if selecting the 'home' button in the action bar to return
128 * up by a single level in your UI rather than back to the top level or front page.
129 *
Adam Powellc29f4e52011-07-13 20:40:52 -0700130 * <p>Setting this option will implicitly enable interaction with the home/up
131 * button. See {@link #setHomeButtonEnabled(boolean)}.
132 *
Adam Powell9ab97872010-10-26 21:47:29 -0700133 * @see #setDisplayOptions(int)
134 * @see #setDisplayOptions(int, int)
135 */
136 public static final int DISPLAY_HOME_AS_UP = 0x4;
137
138 /**
139 * Show the activity title and subtitle, if present.
140 *
141 * @see #setTitle(CharSequence)
142 * @see #setTitle(int)
143 * @see #setSubtitle(CharSequence)
144 * @see #setSubtitle(int)
145 * @see #setDisplayOptions(int)
146 * @see #setDisplayOptions(int, int)
147 */
148 public static final int DISPLAY_SHOW_TITLE = 0x8;
149
150 /**
151 * Show the custom view if one has been set.
152 * @see #setCustomView(View)
153 * @see #setDisplayOptions(int)
154 * @see #setDisplayOptions(int, int)
155 */
156 public static final int DISPLAY_SHOW_CUSTOM = 0x10;
157
158 /**
Adam Powell27cba382013-01-22 18:55:20 -0800159 * Allow the title to wrap onto multiple lines if space is available
160 * @hide pending API approval
161 */
162 public static final int DISPLAY_TITLE_MULTIPLE_LINES = 0x20;
163
164 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700165 * Set the action bar into custom navigation mode, supplying a view
166 * for custom navigation.
167 *
168 * Custom navigation views appear between the application icon and
169 * any action buttons and may use any space available there. Common
170 * use cases for custom navigation views might include an auto-suggesting
171 * address bar for a browser or other navigation mechanisms that do not
172 * translate well to provided navigation modes.
173 *
174 * @param view Custom navigation view to place in the ActionBar.
175 */
176 public abstract void setCustomView(View view);
Adam Powell89e06452010-06-23 20:24:52 -0700177
Adam Powell33b97432010-04-20 10:01:14 -0700178 /**
Adam Powella4082912010-06-04 18:34:02 -0700179 * Set the action bar into custom navigation mode, supplying a view
180 * for custom navigation.
Adam Powell33b97432010-04-20 10:01:14 -0700181 *
Adam Powellef704442010-11-16 14:48:22 -0800182 * <p>Custom navigation views appear between the application icon and
Adam Powell33b97432010-04-20 10:01:14 -0700183 * any action buttons and may use any space available there. Common
Adam Powella4082912010-06-04 18:34:02 -0700184 * use cases for custom navigation views might include an auto-suggesting
185 * address bar for a browser or other navigation mechanisms that do not
Adam Powellef704442010-11-16 14:48:22 -0800186 * translate well to provided navigation modes.</p>
187 *
188 * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
189 * the custom view to be displayed.</p>
Adam Powell33b97432010-04-20 10:01:14 -0700190 *
191 * @param view Custom navigation view to place in the ActionBar.
Adam Powell9ab97872010-10-26 21:47:29 -0700192 * @param layoutParams How this custom view should layout in the bar.
Adam Powellef704442010-11-16 14:48:22 -0800193 *
194 * @see #setDisplayOptions(int, int)
Adam Powell33b97432010-04-20 10:01:14 -0700195 */
Adam Powell9ab97872010-10-26 21:47:29 -0700196 public abstract void setCustomView(View view, LayoutParams layoutParams);
197
198 /**
Adam Powell3f476b32011-01-03 19:25:36 -0800199 * Set the action bar into custom navigation mode, supplying a view
200 * for custom navigation.
201 *
202 * <p>Custom navigation views appear between the application icon and
203 * any action buttons and may use any space available there. Common
204 * use cases for custom navigation views might include an auto-suggesting
205 * address bar for a browser or other navigation mechanisms that do not
206 * translate well to provided navigation modes.</p>
207 *
208 * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
209 * the custom view to be displayed.</p>
210 *
211 * @param resId Resource ID of a layout to inflate into the ActionBar.
212 *
213 * @see #setDisplayOptions(int, int)
214 */
215 public abstract void setCustomView(int resId);
216
217 /**
Adam Powell1969b872011-03-22 11:52:48 -0700218 * Set the icon to display in the 'home' section of the action bar.
219 * The action bar will use an icon specified by its style or the
220 * activity icon by default.
221 *
222 * Whether the home section shows an icon or logo is controlled
223 * by the display option {@link #DISPLAY_USE_LOGO}.
224 *
225 * @param resId Resource ID of a drawable to show as an icon.
226 *
227 * @see #setDisplayUseLogoEnabled(boolean)
228 * @see #setDisplayShowHomeEnabled(boolean)
229 */
230 public abstract void setIcon(int resId);
231
232 /**
233 * Set the icon to display in the 'home' section of the action bar.
234 * The action bar will use an icon specified by its style or the
235 * activity icon by default.
236 *
237 * Whether the home section shows an icon or logo is controlled
238 * by the display option {@link #DISPLAY_USE_LOGO}.
239 *
240 * @param icon Drawable to show as an icon.
241 *
242 * @see #setDisplayUseLogoEnabled(boolean)
243 * @see #setDisplayShowHomeEnabled(boolean)
244 */
245 public abstract void setIcon(Drawable icon);
246
247 /**
248 * Set the logo to display in the 'home' section of the action bar.
249 * The action bar will use a logo specified by its style or the
250 * activity logo by default.
251 *
252 * Whether the home section shows an icon or logo is controlled
253 * by the display option {@link #DISPLAY_USE_LOGO}.
254 *
255 * @param resId Resource ID of a drawable to show as a logo.
256 *
257 * @see #setDisplayUseLogoEnabled(boolean)
258 * @see #setDisplayShowHomeEnabled(boolean)
259 */
260 public abstract void setLogo(int resId);
261
262 /**
263 * Set the logo to display in the 'home' section of the action bar.
264 * The action bar will use a logo specified by its style or the
265 * activity logo by default.
266 *
267 * Whether the home section shows an icon or logo is controlled
268 * by the display option {@link #DISPLAY_USE_LOGO}.
269 *
270 * @param logo Drawable to show as a logo.
271 *
272 * @see #setDisplayUseLogoEnabled(boolean)
273 * @see #setDisplayShowHomeEnabled(boolean)
274 */
275 public abstract void setLogo(Drawable logo);
276
277 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700278 * Set the adapter and navigation callback for list navigation mode.
279 *
280 * The supplied adapter will provide views for the expanded list as well as
281 * the currently selected item. (These may be displayed differently.)
282 *
Adam Powell8515ee82010-11-30 14:09:55 -0800283 * The supplied OnNavigationListener will alert the application when the user
Adam Powell9ab97872010-10-26 21:47:29 -0700284 * changes the current list selection.
285 *
286 * @param adapter An adapter that will provide views both to display
287 * the current navigation selection and populate views
288 * within the dropdown navigation menu.
Adam Powell8515ee82010-11-30 14:09:55 -0800289 * @param callback An OnNavigationListener that will receive events when the user
Adam Powell9ab97872010-10-26 21:47:29 -0700290 * selects a navigation item.
291 */
292 public abstract void setListNavigationCallbacks(SpinnerAdapter adapter,
Adam Powell8515ee82010-11-30 14:09:55 -0800293 OnNavigationListener callback);
Adam Powell9ab97872010-10-26 21:47:29 -0700294
295 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700296 * Set the selected navigation item in list or tabbed navigation modes.
Adam Powell17809772010-07-21 13:25:11 -0700297 *
298 * @param position Position of the item to select.
299 */
300 public abstract void setSelectedNavigationItem(int position);
301
302 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700303 * Get the position of the selected navigation item in list or tabbed navigation modes.
304 *
305 * @return Position of the selected item.
Adam Powell17809772010-07-21 13:25:11 -0700306 */
Adam Powell9ab97872010-10-26 21:47:29 -0700307 public abstract int getSelectedNavigationIndex();
308
309 /**
310 * Get the number of navigation items present in the current navigation mode.
311 *
312 * @return Number of navigation items.
313 */
314 public abstract int getNavigationItemCount();
Adam Powell17809772010-07-21 13:25:11 -0700315
316 /**
Adam Powellef704442010-11-16 14:48:22 -0800317 * Set the action bar's title. This will only be displayed if
318 * {@link #DISPLAY_SHOW_TITLE} is set.
Adam Powell0e94b512010-06-29 17:58:20 -0700319 *
320 * @param title Title to set
Adam Powella66c7b02010-07-28 15:28:25 -0700321 *
322 * @see #setTitle(int)
Adam Powellef704442010-11-16 14:48:22 -0800323 * @see #setDisplayOptions(int, int)
Adam Powell0e94b512010-06-29 17:58:20 -0700324 */
325 public abstract void setTitle(CharSequence title);
326
327 /**
Adam Powellef704442010-11-16 14:48:22 -0800328 * Set the action bar's title. This will only be displayed if
329 * {@link #DISPLAY_SHOW_TITLE} is set.
Adam Powella66c7b02010-07-28 15:28:25 -0700330 *
331 * @param resId Resource ID of title string to set
332 *
333 * @see #setTitle(CharSequence)
Adam Powellef704442010-11-16 14:48:22 -0800334 * @see #setDisplayOptions(int, int)
Adam Powella66c7b02010-07-28 15:28:25 -0700335 */
336 public abstract void setTitle(int resId);
337
338 /**
Adam Powellef704442010-11-16 14:48:22 -0800339 * Set the action bar's subtitle. This will only be displayed if
340 * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the
341 * subtitle entirely.
Adam Powell0e94b512010-06-29 17:58:20 -0700342 *
343 * @param subtitle Subtitle to set
Adam Powella66c7b02010-07-28 15:28:25 -0700344 *
345 * @see #setSubtitle(int)
Adam Powellef704442010-11-16 14:48:22 -0800346 * @see #setDisplayOptions(int, int)
Adam Powell0e94b512010-06-29 17:58:20 -0700347 */
348 public abstract void setSubtitle(CharSequence subtitle);
349
350 /**
Adam Powellef704442010-11-16 14:48:22 -0800351 * Set the action bar's subtitle. This will only be displayed if
352 * {@link #DISPLAY_SHOW_TITLE} is set.
Adam Powella66c7b02010-07-28 15:28:25 -0700353 *
354 * @param resId Resource ID of subtitle string to set
355 *
356 * @see #setSubtitle(CharSequence)
Adam Powellef704442010-11-16 14:48:22 -0800357 * @see #setDisplayOptions(int, int)
Adam Powella66c7b02010-07-28 15:28:25 -0700358 */
359 public abstract void setSubtitle(int resId);
360
361 /**
Adam Powella1700782010-05-13 13:27:35 -0700362 * Set display options. This changes all display option bits at once. To change
363 * a limited subset of display options, see {@link #setDisplayOptions(int, int)}.
Adam Powell33b97432010-04-20 10:01:14 -0700364 *
365 * @param options A combination of the bits defined by the DISPLAY_ constants
366 * defined in ActionBar.
367 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700368 public abstract void setDisplayOptions(@DisplayOptions int options);
Adam Powell33b97432010-04-20 10:01:14 -0700369
370 /**
Adam Powella1700782010-05-13 13:27:35 -0700371 * Set selected display options. Only the options specified by mask will be changed.
372 * To change all display option bits at once, see {@link #setDisplayOptions(int)}.
373 *
Adam Powell9ab97872010-10-26 21:47:29 -0700374 * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the
375 * {@link #DISPLAY_SHOW_HOME} option.
Ben Komalo5ad7af62010-11-01 12:04:51 -0700376 * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)
Adam Powell9ab97872010-10-26 21:47:29 -0700377 * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}.
Adam Powella1700782010-05-13 13:27:35 -0700378 *
379 * @param options A combination of the bits defined by the DISPLAY_ constants
380 * defined in ActionBar.
381 * @param mask A bit mask declaring which display options should be changed.
382 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700383 public abstract void setDisplayOptions(@DisplayOptions int options, @DisplayOptions int mask);
Adam Powell3f476b32011-01-03 19:25:36 -0800384
385 /**
386 * Set whether to display the activity logo rather than the activity icon.
387 * A logo is often a wider, more detailed image.
388 *
389 * <p>To set several display options at once, see the setDisplayOptions methods.
390 *
391 * @param useLogo true to use the activity logo, false to use the activity icon.
392 *
393 * @see #setDisplayOptions(int)
394 * @see #setDisplayOptions(int, int)
395 */
396 public abstract void setDisplayUseLogoEnabled(boolean useLogo);
397
398 /**
399 * Set whether to include the application home affordance in the action bar.
400 * Home is presented as either an activity icon or logo.
401 *
402 * <p>To set several display options at once, see the setDisplayOptions methods.
403 *
404 * @param showHome true to show home, false otherwise.
405 *
406 * @see #setDisplayOptions(int)
407 * @see #setDisplayOptions(int, int)
408 */
409 public abstract void setDisplayShowHomeEnabled(boolean showHome);
410
411 /**
412 * Set whether home should be displayed as an "up" affordance.
413 * Set this to true if selecting "home" returns up by a single level in your UI
414 * rather than back to the top level or front page.
415 *
416 * <p>To set several display options at once, see the setDisplayOptions methods.
417 *
418 * @param showHomeAsUp true to show the user that selecting home will return one
419 * level up rather than to the top level of the app.
420 *
421 * @see #setDisplayOptions(int)
422 * @see #setDisplayOptions(int, int)
423 */
424 public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
425
426 /**
427 * Set whether an activity title/subtitle should be displayed.
428 *
429 * <p>To set several display options at once, see the setDisplayOptions methods.
430 *
431 * @param showTitle true to display a title/subtitle if present.
432 *
433 * @see #setDisplayOptions(int)
434 * @see #setDisplayOptions(int, int)
435 */
436 public abstract void setDisplayShowTitleEnabled(boolean showTitle);
437
438 /**
439 * Set whether a custom view should be displayed, if set.
440 *
441 * <p>To set several display options at once, see the setDisplayOptions methods.
442 *
443 * @param showCustom true if the currently set custom view should be displayed, false otherwise.
444 *
445 * @see #setDisplayOptions(int)
446 * @see #setDisplayOptions(int, int)
447 */
448 public abstract void setDisplayShowCustomEnabled(boolean showCustom);
449
Adam Powella1700782010-05-13 13:27:35 -0700450 /**
Adam Powellf88b9152011-09-07 14:54:32 -0700451 * Set the ActionBar's background. This will be used for the primary
452 * action bar.
Adam Powell33b97432010-04-20 10:01:14 -0700453 *
454 * @param d Background drawable
Adam Powellf88b9152011-09-07 14:54:32 -0700455 * @see #setStackedBackgroundDrawable(Drawable)
456 * @see #setSplitBackgroundDrawable(Drawable)
Adam Powell33b97432010-04-20 10:01:14 -0700457 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700458 public abstract void setBackgroundDrawable(@Nullable Drawable d);
Adam Powellef704442010-11-16 14:48:22 -0800459
460 /**
Adam Powellf88b9152011-09-07 14:54:32 -0700461 * Set the ActionBar's stacked background. This will appear
462 * in the second row/stacked bar on some devices and configurations.
463 *
464 * @param d Background drawable for the stacked row
465 */
Adam Powell01453222011-09-07 16:13:36 -0700466 public void setStackedBackgroundDrawable(Drawable d) { }
Adam Powellf88b9152011-09-07 14:54:32 -0700467
468 /**
469 * Set the ActionBar's split background. This will appear in
470 * the split action bar containing menu-provided action buttons
471 * on some devices and configurations.
Scott Maine797ed62011-09-22 16:17:45 -0700472 * <p>You can enable split action bar with {@link android.R.attr#uiOptions}
Adam Powellf88b9152011-09-07 14:54:32 -0700473 *
474 * @param d Background drawable for the split bar
475 */
Adam Powell01453222011-09-07 16:13:36 -0700476 public void setSplitBackgroundDrawable(Drawable d) { }
Adam Powellf88b9152011-09-07 14:54:32 -0700477
478 /**
Adam Powellef704442010-11-16 14:48:22 -0800479 * @return The current custom view.
480 */
481 public abstract View getCustomView();
482
Adam Powell33b97432010-04-20 10:01:14 -0700483 /**
Adam Powella4082912010-06-04 18:34:02 -0700484 * Returns the current ActionBar title in standard mode.
485 * Returns null if {@link #getNavigationMode()} would not return
486 * {@link #NAVIGATION_MODE_STANDARD}.
487 *
488 * @return The current ActionBar title or null.
Adam Powell33b97432010-04-20 10:01:14 -0700489 */
490 public abstract CharSequence getTitle();
491
492 /**
Adam Powella4082912010-06-04 18:34:02 -0700493 * Returns the current ActionBar subtitle in standard mode.
494 * Returns null if {@link #getNavigationMode()} would not return
495 * {@link #NAVIGATION_MODE_STANDARD}.
496 *
497 * @return The current ActionBar subtitle or null.
Adam Powell33b97432010-04-20 10:01:14 -0700498 */
499 public abstract CharSequence getSubtitle();
500
501 /**
Adam Powella4082912010-06-04 18:34:02 -0700502 * Returns the current navigation mode. The result will be one of:
503 * <ul>
504 * <li>{@link #NAVIGATION_MODE_STANDARD}</li>
Adam Powell9ab97872010-10-26 21:47:29 -0700505 * <li>{@link #NAVIGATION_MODE_LIST}</li>
Adam Powella4082912010-06-04 18:34:02 -0700506 * <li>{@link #NAVIGATION_MODE_TABS}</li>
Adam Powella4082912010-06-04 18:34:02 -0700507 * </ul>
508 *
Adam Powell33b97432010-04-20 10:01:14 -0700509 * @return The current navigation mode.
510 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700511 @NavigationMode
Adam Powell33b97432010-04-20 10:01:14 -0700512 public abstract int getNavigationMode();
Adam Powell9ab97872010-10-26 21:47:29 -0700513
514 /**
515 * Set the current navigation mode.
516 *
517 * @param mode The new mode to set.
518 * @see #NAVIGATION_MODE_STANDARD
519 * @see #NAVIGATION_MODE_LIST
520 * @see #NAVIGATION_MODE_TABS
521 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700522 public abstract void setNavigationMode(@NavigationMode int mode);
Adam Powell9ab97872010-10-26 21:47:29 -0700523
Adam Powell33b97432010-04-20 10:01:14 -0700524 /**
525 * @return The current set of display options.
526 */
527 public abstract int getDisplayOptions();
Adam Powell661c9082010-07-02 10:09:44 -0700528
529 /**
Adam Powell661c9082010-07-02 10:09:44 -0700530 * Create and return a new {@link Tab}.
531 * This tab will not be included in the action bar until it is added.
532 *
Dianne Hackborn2f048832011-06-16 13:31:57 -0700533 * <p>Very often tabs will be used to switch between {@link Fragment}
534 * objects. Here is a typical implementation of such tabs:</p>
535 *
536 * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java
537 * complete}
538 *
Adam Powell661c9082010-07-02 10:09:44 -0700539 * @return A new Tab
540 *
541 * @see #addTab(Tab)
Adam Powell661c9082010-07-02 10:09:44 -0700542 */
543 public abstract Tab newTab();
544
545 /**
546 * 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 -0700547 * If this is the first tab to be added it will become the selected tab.
Adam Powell661c9082010-07-02 10:09:44 -0700548 *
549 * @param tab Tab to add
550 */
551 public abstract void addTab(Tab tab);
552
553 /**
Adam Powell81b89442010-11-02 17:58:56 -0700554 * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
555 *
556 * @param tab Tab to add
557 * @param setSelected True if the added tab should become the selected tab.
558 */
559 public abstract void addTab(Tab tab, boolean setSelected);
560
561 /**
Adam Powell2b6230e2010-09-07 17:55:25 -0700562 * Add a tab for use in tabbed navigation mode. The tab will be inserted at
Adam Powell81b89442010-11-02 17:58:56 -0700563 * <code>position</code>. If this is the first tab to be added it will become
564 * the selected tab.
Adam Powell661c9082010-07-02 10:09:44 -0700565 *
566 * @param tab The tab to add
567 * @param position The new position of the tab
568 */
Adam Powell2b6230e2010-09-07 17:55:25 -0700569 public abstract void addTab(Tab tab, int position);
Adam Powell661c9082010-07-02 10:09:44 -0700570
571 /**
Adam Powell81b89442010-11-02 17:58:56 -0700572 * Add a tab for use in tabbed navigation mode. The tab will be insterted at
573 * <code>position</code>.
574 *
575 * @param tab The tab to add
576 * @param position The new position of the tab
577 * @param setSelected True if the added tab should become the selected tab.
578 */
579 public abstract void addTab(Tab tab, int position, boolean setSelected);
580
581 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700582 * Remove a tab from the action bar. If the removed tab was selected it will be deselected
583 * and another tab will be selected if present.
Adam Powell661c9082010-07-02 10:09:44 -0700584 *
585 * @param tab The tab to remove
586 */
587 public abstract void removeTab(Tab tab);
588
589 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700590 * Remove a tab from the action bar. If the removed tab was selected it will be deselected
591 * and another tab will be selected if present.
Adam Powell661c9082010-07-02 10:09:44 -0700592 *
593 * @param position Position of the tab to remove
594 */
595 public abstract void removeTabAt(int position);
596
597 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700598 * Remove all tabs from the action bar and deselect the current tab.
599 */
600 public abstract void removeAllTabs();
601
602 /**
Adam Powell661c9082010-07-02 10:09:44 -0700603 * Select the specified tab. If it is not a child of this action bar it will be added.
604 *
Adam Powell9ab97872010-10-26 21:47:29 -0700605 * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p>
606 *
Adam Powell661c9082010-07-02 10:09:44 -0700607 * @param tab Tab to select
608 */
609 public abstract void selectTab(Tab tab);
610
611 /**
Adam Powell2b6230e2010-09-07 17:55:25 -0700612 * Returns the currently selected tab if in tabbed navigation mode and there is at least
613 * one tab present.
614 *
615 * @return The currently selected tab or null
616 */
617 public abstract Tab getSelectedTab();
618
619 /**
Adam Powell9ab97872010-10-26 21:47:29 -0700620 * Returns the tab at the specified index.
621 *
622 * @param index Index value in the range 0-get
623 * @return
624 */
625 public abstract Tab getTabAt(int index);
626
627 /**
Adam Powell0c24a552010-11-03 16:44:11 -0700628 * Returns the number of tabs currently registered with the action bar.
629 * @return Tab count
630 */
631 public abstract int getTabCount();
632
633 /**
Adam Powell6b336f82010-08-10 20:13:01 -0700634 * Retrieve the current height of the ActionBar.
635 *
636 * @return The ActionBar's height
637 */
638 public abstract int getHeight();
639
640 /**
641 * Show the ActionBar if it is not currently showing.
642 * If the window hosting the ActionBar does not have the feature
643 * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
644 * content to fit the new space available.
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700645 *
646 * <p>If you are hiding the ActionBar through
647 * {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN},
648 * you should not call this function directly.
Adam Powell6b336f82010-08-10 20:13:01 -0700649 */
650 public abstract void show();
651
652 /**
Scott Maine797ed62011-09-22 16:17:45 -0700653 * Hide the ActionBar if it is currently showing.
Adam Powell6b336f82010-08-10 20:13:01 -0700654 * If the window hosting the ActionBar does not have the feature
655 * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
656 * content to fit the new space available.
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700657 *
658 * <p>Instead of calling this function directly, you can also cause an
659 * ActionBar using the overlay feature to hide through
660 * {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN}.
661 * Hiding the ActionBar through this system UI flag allows you to more
662 * seamlessly hide it in conjunction with other screen decorations.
Adam Powell6b336f82010-08-10 20:13:01 -0700663 */
664 public abstract void hide();
665
666 /**
667 * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise.
668 */
669 public abstract boolean isShowing();
670
671 /**
Adam Powell8515ee82010-11-30 14:09:55 -0800672 * Add a listener that will respond to menu visibility change events.
673 *
674 * @param listener The new listener to add
Adam Powell89e06452010-06-23 20:24:52 -0700675 */
Adam Powell8515ee82010-11-30 14:09:55 -0800676 public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener);
677
678 /**
679 * Remove a menu visibility listener. This listener will no longer receive menu
680 * visibility change events.
681 *
682 * @param listener A listener to remove that was previously added
683 */
684 public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener);
685
686 /**
Adam Powellc29f4e52011-07-13 20:40:52 -0700687 * Enable or disable the "home" button in the corner of the action bar. (Note that this
688 * is the application home/up affordance on the action bar, not the systemwide home
689 * button.)
690 *
691 * <p>This defaults to true for packages targeting &lt; API 14. For packages targeting
692 * API 14 or greater, the application should call this method to enable interaction
693 * with the home/up affordance.
694 *
695 * <p>Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable
696 * the home button.
697 *
698 * @param enabled true to enable the home button, false to disable the home button.
699 */
Adam Powell88ab6972011-07-28 11:25:01 -0700700 public void setHomeButtonEnabled(boolean enabled) { }
701
702 /**
703 * Returns a {@link Context} with an appropriate theme for creating views that
704 * will appear in the action bar. If you are inflating or instantiating custom views
705 * that will appear in an action bar, you should use the Context returned by this method.
706 * (This includes adapters used for list navigation mode.)
707 * This will ensure that views contrast properly against the action bar.
708 *
709 * @return A themed Context for creating views
710 */
711 public Context getThemedContext() { return null; }
Adam Powellc29f4e52011-07-13 20:40:52 -0700712
713 /**
Adam Powell27cba382013-01-22 18:55:20 -0800714 * Returns true if the Title field has been truncated during layout for lack
715 * of available space.
716 *
717 * @return true if the Title field has been truncated
718 * @hide pending API approval
719 */
720 public boolean isTitleTruncated() { return false; }
721
722 /**
Adam Powelle0e2f4f2013-04-05 16:27:35 -0700723 * Set an alternate drawable to display next to the icon/logo/title
724 * when {@link #DISPLAY_HOME_AS_UP} is enabled. This can be useful if you are using
725 * this mode to display an alternate selection for up navigation, such as a sliding drawer.
726 *
727 * <p>If you pass <code>null</code> to this method, the default drawable from the theme
728 * will be used.</p>
729 *
730 * <p>If you implement alternate or intermediate behavior around Up, you should also
731 * call {@link #setHomeActionContentDescription(int) setHomeActionContentDescription()}
732 * to provide a correct description of the action for accessibility support.</p>
733 *
734 * @param indicator A drawable to use for the up indicator, or null to use the theme's default
735 *
736 * @see #setDisplayOptions(int, int)
737 * @see #setDisplayHomeAsUpEnabled(boolean)
738 * @see #setHomeActionContentDescription(int)
739 */
740 public void setHomeAsUpIndicator(Drawable indicator) { }
741
742 /**
743 * Set an alternate drawable to display next to the icon/logo/title
744 * when {@link #DISPLAY_HOME_AS_UP} is enabled. This can be useful if you are using
745 * this mode to display an alternate selection for up navigation, such as a sliding drawer.
746 *
747 * <p>If you pass <code>0</code> to this method, the default drawable from the theme
748 * will be used.</p>
749 *
750 * <p>If you implement alternate or intermediate behavior around Up, you should also
751 * call {@link #setHomeActionContentDescription(int) setHomeActionContentDescription()}
752 * to provide a correct description of the action for accessibility support.</p>
753 *
754 * @param resId Resource ID of a drawable to use for the up indicator, or null
755 * to use the theme's default
756 *
757 * @see #setDisplayOptions(int, int)
758 * @see #setDisplayHomeAsUpEnabled(boolean)
759 * @see #setHomeActionContentDescription(int)
760 */
761 public void setHomeAsUpIndicator(int resId) { }
762
763 /**
764 * Set an alternate description for the Home/Up action, when enabled.
765 *
766 * <p>This description is commonly used for accessibility/screen readers when
767 * the Home action is enabled. (See {@link #setDisplayHomeAsUpEnabled(boolean)}.)
768 * Examples of this are, "Navigate Home" or "Navigate Up" depending on the
769 * {@link #DISPLAY_HOME_AS_UP} display option. If you have changed the home-as-up
770 * indicator using {@link #setHomeAsUpIndicator(int)} to indicate more specific
771 * functionality such as a sliding drawer, you should also set this to accurately
772 * describe the action.</p>
773 *
774 * <p>Setting this to <code>null</code> will use the system default description.</p>
775 *
776 * @param description New description for the Home action when enabled
777 * @see #setHomeAsUpIndicator(int)
778 * @see #setHomeAsUpIndicator(android.graphics.drawable.Drawable)
779 */
780 public void setHomeActionContentDescription(CharSequence description) { }
781
782 /**
783 * Set an alternate description for the Home/Up action, when enabled.
784 *
785 * <p>This description is commonly used for accessibility/screen readers when
786 * the Home action is enabled. (See {@link #setDisplayHomeAsUpEnabled(boolean)}.)
787 * Examples of this are, "Navigate Home" or "Navigate Up" depending on the
788 * {@link #DISPLAY_HOME_AS_UP} display option. If you have changed the home-as-up
789 * indicator using {@link #setHomeAsUpIndicator(int)} to indicate more specific
790 * functionality such as a sliding drawer, you should also set this to accurately
791 * describe the action.</p>
792 *
793 * <p>Setting this to <code>0</code> will use the system default description.</p>
794 *
795 * @param resId Resource ID of a string to use as the new description
796 * for the Home action when enabled
797 * @see #setHomeAsUpIndicator(int)
798 * @see #setHomeAsUpIndicator(android.graphics.drawable.Drawable)
799 */
800 public void setHomeActionContentDescription(int resId) { }
801
802 /**
Adam Powell8515ee82010-11-30 14:09:55 -0800803 * Listener interface for ActionBar navigation events.
804 */
805 public interface OnNavigationListener {
Adam Powell33b97432010-04-20 10:01:14 -0700806 /**
Adam Powella4082912010-06-04 18:34:02 -0700807 * This method is called whenever a navigation item in your action bar
808 * is selected.
809 *
810 * @param itemPosition Position of the item clicked.
811 * @param itemId ID of the item clicked.
812 * @return True if the event was handled, false otherwise.
813 */
814 public boolean onNavigationItemSelected(int itemPosition, long itemId);
Adam Powell33b97432010-04-20 10:01:14 -0700815 }
Adam Powell661c9082010-07-02 10:09:44 -0700816
817 /**
Adam Powell8515ee82010-11-30 14:09:55 -0800818 * Listener for receiving events when action bar menus are shown or hidden.
819 */
820 public interface OnMenuVisibilityListener {
821 /**
822 * Called when an action bar menu is shown or hidden. Applications may want to use
823 * this to tune auto-hiding behavior for the action bar or pause/resume video playback,
824 * gameplay, or other activity within the main content area.
825 *
826 * @param isVisible True if an action bar menu is now visible, false if no action bar
827 * menus are visible.
828 */
829 public void onMenuVisibilityChanged(boolean isVisible);
830 }
831
832 /**
Adam Powell661c9082010-07-02 10:09:44 -0700833 * A tab in the action bar.
834 *
835 * <p>Tabs manage the hiding and showing of {@link Fragment}s.
836 */
837 public static abstract class Tab {
838 /**
839 * An invalid position for a tab.
840 *
841 * @see #getPosition()
842 */
843 public static final int INVALID_POSITION = -1;
844
845 /**
846 * Return the current position of this tab in the action bar.
847 *
848 * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in
849 * the action bar.
850 */
851 public abstract int getPosition();
852
853 /**
854 * Return the icon associated with this tab.
855 *
856 * @return The tab's icon
857 */
858 public abstract Drawable getIcon();
859
860 /**
861 * Return the text of this tab.
862 *
863 * @return The tab's text
864 */
865 public abstract CharSequence getText();
866
867 /**
868 * Set the icon displayed on this tab.
869 *
870 * @param icon The drawable to use as an icon
Adam Powell9ab97872010-10-26 21:47:29 -0700871 * @return The current instance for call chaining
Adam Powell661c9082010-07-02 10:09:44 -0700872 */
Adam Powell9ab97872010-10-26 21:47:29 -0700873 public abstract Tab setIcon(Drawable icon);
Adam Powell661c9082010-07-02 10:09:44 -0700874
875 /**
Adam Powell32555f32010-11-17 13:49:22 -0800876 * Set the icon displayed on this tab.
877 *
878 * @param resId Resource ID referring to the drawable to use as an icon
879 * @return The current instance for call chaining
880 */
881 public abstract Tab setIcon(int resId);
882
883 /**
Adam Powell661c9082010-07-02 10:09:44 -0700884 * Set the text displayed on this tab. Text may be truncated if there is not
885 * room to display the entire string.
886 *
887 * @param text The text to display
Adam Powell9ab97872010-10-26 21:47:29 -0700888 * @return The current instance for call chaining
Adam Powell661c9082010-07-02 10:09:44 -0700889 */
Adam Powell9ab97872010-10-26 21:47:29 -0700890 public abstract Tab setText(CharSequence text);
Adam Powell661c9082010-07-02 10:09:44 -0700891
892 /**
Adam Powell32555f32010-11-17 13:49:22 -0800893 * Set the text displayed on this tab. Text may be truncated if there is not
894 * room to display the entire string.
895 *
896 * @param resId A resource ID referring to the text that should be displayed
897 * @return The current instance for call chaining
898 */
899 public abstract Tab setText(int resId);
900
901 /**
Adam Powell2b6230e2010-09-07 17:55:25 -0700902 * Set a custom view to be used for this tab. This overrides values set by
903 * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
Adam Powell661c9082010-07-02 10:09:44 -0700904 *
Adam Powell2b6230e2010-09-07 17:55:25 -0700905 * @param view Custom view to be used as a tab.
Adam Powell9ab97872010-10-26 21:47:29 -0700906 * @return The current instance for call chaining
Adam Powell661c9082010-07-02 10:09:44 -0700907 */
Adam Powell9ab97872010-10-26 21:47:29 -0700908 public abstract Tab setCustomView(View view);
Adam Powell661c9082010-07-02 10:09:44 -0700909
910 /**
Adam Powell32555f32010-11-17 13:49:22 -0800911 * Set a custom view to be used for this tab. This overrides values set by
912 * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
913 *
914 * @param layoutResId A layout resource to inflate and use as a custom tab view
915 * @return The current instance for call chaining
916 */
917 public abstract Tab setCustomView(int layoutResId);
918
919 /**
Adam Powell2b6230e2010-09-07 17:55:25 -0700920 * Retrieve a previously set custom view for this tab.
Adam Powell661c9082010-07-02 10:09:44 -0700921 *
Adam Powell2b6230e2010-09-07 17:55:25 -0700922 * @return The custom view set by {@link #setCustomView(View)}.
Adam Powell661c9082010-07-02 10:09:44 -0700923 */
Adam Powell2b6230e2010-09-07 17:55:25 -0700924 public abstract View getCustomView();
925
926 /**
927 * Give this Tab an arbitrary object to hold for later use.
928 *
929 * @param obj Object to store
Adam Powell9ab97872010-10-26 21:47:29 -0700930 * @return The current instance for call chaining
Adam Powell2b6230e2010-09-07 17:55:25 -0700931 */
Adam Powell9ab97872010-10-26 21:47:29 -0700932 public abstract Tab setTag(Object obj);
Adam Powell2b6230e2010-09-07 17:55:25 -0700933
934 /**
935 * @return This Tab's tag object.
936 */
937 public abstract Object getTag();
938
939 /**
940 * Set the {@link TabListener} that will handle switching to and from this tab.
941 * All tabs must have a TabListener set before being added to the ActionBar.
942 *
943 * @param listener Listener to handle tab selection events
Adam Powell9ab97872010-10-26 21:47:29 -0700944 * @return The current instance for call chaining
Adam Powell2b6230e2010-09-07 17:55:25 -0700945 */
Adam Powell9ab97872010-10-26 21:47:29 -0700946 public abstract Tab setTabListener(TabListener listener);
Adam Powell661c9082010-07-02 10:09:44 -0700947
948 /**
949 * Select this tab. Only valid if the tab has been added to the action bar.
950 */
951 public abstract void select();
Adam Powell94e56ef2011-09-06 21:22:22 -0700952
953 /**
954 * Set a description of this tab's content for use in accessibility support.
955 * If no content description is provided the title will be used.
956 *
957 * @param resId A resource ID referring to the description text
958 * @return The current instance for call chaining
959 * @see #setContentDescription(CharSequence)
960 * @see #getContentDescription()
961 */
962 public abstract Tab setContentDescription(int resId);
963
964 /**
965 * Set a description of this tab's content for use in accessibility support.
966 * If no content description is provided the title will be used.
967 *
968 * @param contentDesc Description of this tab's content
969 * @return The current instance for call chaining
970 * @see #setContentDescription(int)
971 * @see #getContentDescription()
972 */
973 public abstract Tab setContentDescription(CharSequence contentDesc);
974
975 /**
976 * Gets a brief description of this tab's content for use in accessibility support.
977 *
978 * @return Description of this tab's content
979 * @see #setContentDescription(CharSequence)
980 * @see #setContentDescription(int)
981 */
982 public abstract CharSequence getContentDescription();
Adam Powell661c9082010-07-02 10:09:44 -0700983 }
Adam Powell2b6230e2010-09-07 17:55:25 -0700984
985 /**
986 * Callback interface invoked when a tab is focused, unfocused, added, or removed.
987 */
988 public interface TabListener {
989 /**
990 * Called when a tab enters the selected state.
991 *
992 * @param tab The tab that was selected
993 * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
994 * during a tab switch. The previous tab's unselect and this tab's select will be
Adam Powell0c24a552010-11-03 16:44:11 -0700995 * executed in a single transaction. This FragmentTransaction does not support
996 * being added to the back stack.
Adam Powell2b6230e2010-09-07 17:55:25 -0700997 */
998 public void onTabSelected(Tab tab, FragmentTransaction ft);
999
1000 /**
1001 * Called when a tab exits the selected state.
1002 *
1003 * @param tab The tab that was unselected
1004 * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
1005 * during a tab switch. This tab's unselect and the newly selected tab's select
Adam Powell0c24a552010-11-03 16:44:11 -07001006 * will be executed in a single transaction. This FragmentTransaction does not
1007 * support being added to the back stack.
Adam Powell2b6230e2010-09-07 17:55:25 -07001008 */
1009 public void onTabUnselected(Tab tab, FragmentTransaction ft);
Adam Powell7f9b9052010-10-19 16:56:07 -07001010
1011 /**
1012 * Called when a tab that is already selected is chosen again by the user.
1013 * Some applications may use this action to return to the top level of a category.
1014 *
1015 * @param tab The tab that was reselected.
1016 * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
Adam Powell0c24a552010-11-03 16:44:11 -07001017 * once this method returns. This FragmentTransaction does not support
1018 * being added to the back stack.
Adam Powell7f9b9052010-10-19 16:56:07 -07001019 */
1020 public void onTabReselected(Tab tab, FragmentTransaction ft);
Adam Powell2b6230e2010-09-07 17:55:25 -07001021 }
Adam Powell9ab97872010-10-26 21:47:29 -07001022
1023 /**
1024 * Per-child layout information associated with action bar custom views.
1025 *
1026 * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity
1027 */
1028 public static class LayoutParams extends MarginLayoutParams {
1029 /**
1030 * Gravity for the view associated with these LayoutParams.
1031 *
1032 * @see android.view.Gravity
1033 */
1034 @ViewDebug.ExportedProperty(category = "layout", mapping = {
1035 @ViewDebug.IntToString(from = -1, to = "NONE"),
1036 @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"),
1037 @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"),
1038 @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"),
1039 @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"),
1040 @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"),
Fabrice Di Megliocf1ba022012-06-25 15:49:11 -07001041 @ViewDebug.IntToString(from = Gravity.START, to = "START"),
1042 @ViewDebug.IntToString(from = Gravity.END, to = "END"),
Adam Powell9ab97872010-10-26 21:47:29 -07001043 @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"),
1044 @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"),
1045 @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),
1046 @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"),
1047 @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"),
1048 @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL")
1049 })
Fabrice Di Megliocf1ba022012-06-25 15:49:11 -07001050 public int gravity = Gravity.NO_GRAVITY;
Adam Powell9ab97872010-10-26 21:47:29 -07001051
Tor Norbyed9273d62013-05-30 15:59:53 -07001052 public LayoutParams(@NonNull Context c, AttributeSet attrs) {
Adam Powell9ab97872010-10-26 21:47:29 -07001053 super(c, attrs);
1054
1055 TypedArray a = c.obtainStyledAttributes(attrs,
1056 com.android.internal.R.styleable.ActionBar_LayoutParams);
1057 gravity = a.getInt(
Fabrice Di Megliocf1ba022012-06-25 15:49:11 -07001058 com.android.internal.R.styleable.ActionBar_LayoutParams_layout_gravity,
1059 Gravity.NO_GRAVITY);
Dianne Hackbornab0f4852011-09-12 16:59:06 -07001060 a.recycle();
Adam Powell9ab97872010-10-26 21:47:29 -07001061 }
1062
1063 public LayoutParams(int width, int height) {
1064 super(width, height);
Fabrice Di Megliocf1ba022012-06-25 15:49:11 -07001065 this.gravity = Gravity.CENTER_VERTICAL | Gravity.START;
Adam Powell9ab97872010-10-26 21:47:29 -07001066 }
1067
1068 public LayoutParams(int width, int height, int gravity) {
1069 super(width, height);
1070 this.gravity = gravity;
1071 }
1072
1073 public LayoutParams(int gravity) {
1074 this(WRAP_CONTENT, MATCH_PARENT, gravity);
1075 }
1076
1077 public LayoutParams(LayoutParams source) {
1078 super(source);
1079
1080 this.gravity = source.gravity;
1081 }
1082
1083 public LayoutParams(ViewGroup.LayoutParams source) {
1084 super(source);
1085 }
1086 }
Adam Powell33b97432010-04-20 10:01:14 -07001087}