Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.app; |
| 18 | |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 19 | import android.annotation.DrawableRes; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 20 | import android.annotation.IntDef; |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 21 | import android.annotation.LayoutRes; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 22 | import android.annotation.NonNull; |
| 23 | import android.annotation.Nullable; |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 24 | import android.annotation.StringRes; |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 25 | import android.annotation.UnsupportedAppUsage; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 26 | import android.content.Context; |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 27 | import android.content.res.Configuration; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 28 | import android.content.res.TypedArray; |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 29 | import android.graphics.drawable.Drawable; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 30 | import android.util.AttributeSet; |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 31 | import android.view.ActionMode; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 32 | import android.view.Gravity; |
Adam Powell | 07a7454 | 2014-05-30 15:52:44 -0700 | [diff] [blame] | 33 | import android.view.KeyEvent; |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 34 | import android.view.View; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 35 | import android.view.ViewDebug; |
| 36 | import android.view.ViewGroup; |
Siva Velusamy | 94a6d15 | 2015-05-05 15:07:00 -0700 | [diff] [blame] | 37 | import android.view.ViewHierarchyEncoder; |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 38 | import android.view.Window; |
Ashley Rose | de3b4a7 | 2019-03-04 16:44:07 -0500 | [diff] [blame] | 39 | import android.view.inspector.InspectableProperty; |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 40 | import android.widget.SpinnerAdapter; |
Vadim Tryshev | 1abe85c | 2017-01-06 19:30:00 -0800 | [diff] [blame] | 41 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 42 | import java.lang.annotation.Retention; |
| 43 | import java.lang.annotation.RetentionPolicy; |
| 44 | |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 45 | /** |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 46 | * A primary toolbar within the activity that may display the activity title, application-level |
| 47 | * navigation affordances, and other interactive items. |
| 48 | * |
Scott Main | e797ed6 | 2011-09-22 16:17:45 -0700 | [diff] [blame] | 49 | * <p>Beginning with Android 3.0 (API level 11), the action bar appears at the top of an |
| 50 | * activity's window when the activity uses the system's {@link |
| 51 | * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default. |
| 52 | * You may otherwise add the action bar by calling {@link |
| 53 | * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a |
| 54 | * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property. |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 55 | * </p> |
| 56 | * |
| 57 | * <p>Beginning with Android L (API level 21), the action bar may be represented by any |
| 58 | * Toolbar widget within the application layout. The application may signal to the Activity |
| 59 | * which Toolbar should be treated as the Activity's action bar. Activities that use this |
| 60 | * feature should use one of the supplied <code>.NoActionBar</code> themes, set the |
| 61 | * {@link android.R.styleable#Theme_windowActionBar windowActionBar} attribute to <code>false</code> |
| 62 | * or otherwise not request the window feature.</p> |
| 63 | * |
| 64 | * <p>By adjusting the window features requested by the theme and the layouts used for |
| 65 | * an Activity's content view, an app can use the standard system action bar on older platform |
| 66 | * releases and the newer inline toolbars on newer platform releases. The <code>ActionBar</code> |
| 67 | * object obtained from the Activity can be used to control either configuration transparently.</p> |
| 68 | * |
| 69 | * <p>When using the Holo themes the action bar shows the application icon on |
Scott Main | e797ed6 | 2011-09-22 16:17:45 -0700 | [diff] [blame] | 70 | * the left, followed by the activity title. If your activity has an options menu, you can make |
| 71 | * select items accessible directly from the action bar as "action items". You can also |
| 72 | * modify various characteristics of the action bar or remove it completely.</p> |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 73 | * |
Alan Viverette | 830960c | 2014-06-06 15:48:55 -0700 | [diff] [blame] | 74 | * <p>When using the Material themes (default in API 21 or newer) the navigation button |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 75 | * (formerly "Home") takes over the space previously occupied by the application icon. |
| 76 | * Apps wishing to express a stronger branding should use their brand colors heavily |
| 77 | * in the action bar and other application chrome or use a {@link #setLogo(int) logo} |
| 78 | * in place of their standard title text.</p> |
| 79 | * |
Scott Main | 36193d0 | 2011-07-12 15:24:01 -0700 | [diff] [blame] | 80 | * <p>From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link |
| 81 | * android.app.Activity#getActionBar getActionBar()}.</p> |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 82 | * |
Scott Main | e797ed6 | 2011-09-22 16:17:45 -0700 | [diff] [blame] | 83 | * <p>In some cases, the action bar may be overlayed by another bar that enables contextual actions, |
| 84 | * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in |
| 85 | * your activity, you can enable an action mode that offers actions specific to the selected |
| 86 | * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the |
| 87 | * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 88 | * {@link ActionBar}.</p> |
| 89 | * |
Joe Fernandez | b54e7a3 | 2011-10-03 15:09:50 -0700 | [diff] [blame] | 90 | * <div class="special reference"> |
| 91 | * <h3>Developer Guides</h3> |
| 92 | * <p>For information about how to use the action bar, including how to add action items, navigation |
| 93 | * modes and more, read the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action |
| 94 | * Bar</a> developer guide.</p> |
| 95 | * </div> |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 96 | */ |
| 97 | public abstract class ActionBar { |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 98 | /** @hide */ |
| 99 | @Retention(RetentionPolicy.SOURCE) |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 100 | @IntDef(prefix = { "NAVIGATION_MODE_" }, value = { |
| 101 | NAVIGATION_MODE_STANDARD, |
| 102 | NAVIGATION_MODE_LIST, |
| 103 | NAVIGATION_MODE_TABS |
| 104 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 105 | public @interface NavigationMode {} |
| 106 | |
Adam Powell | a170078 | 2010-05-13 13:27:35 -0700 | [diff] [blame] | 107 | /** |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 108 | * Standard navigation mode. Consists of either a logo or icon |
Adam Powell | a170078 | 2010-05-13 13:27:35 -0700 | [diff] [blame] | 109 | * and title text with an optional subtitle. Clicking any of these elements |
Adam Powell | cf03576 | 2010-12-06 11:49:45 -0800 | [diff] [blame] | 110 | * will dispatch onOptionsItemSelected to the host Activity with |
Adam Powell | a170078 | 2010-05-13 13:27:35 -0700 | [diff] [blame] | 111 | * a MenuItem with item ID android.R.id.home. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 112 | * |
| 113 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 114 | * toolbar action bars. Consider using other |
| 115 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 116 | * navigation patterns</a> instead. |
Adam Powell | a170078 | 2010-05-13 13:27:35 -0700 | [diff] [blame] | 117 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 118 | @Deprecated |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 119 | public static final int NAVIGATION_MODE_STANDARD = 0; |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 120 | |
| 121 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 122 | * List navigation mode. Instead of static title text this mode |
| 123 | * presents a list menu for navigation within the activity. |
| 124 | * e.g. this might be presented to the user as a dropdown list. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 125 | * |
| 126 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 127 | * toolbar action bars. Consider using other |
| 128 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 129 | * navigation patterns</a> instead. |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 130 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 131 | @Deprecated |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 132 | public static final int NAVIGATION_MODE_LIST = 1; |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 133 | |
| 134 | /** |
| 135 | * Tab navigation mode. Instead of static title text this mode |
| 136 | * presents a series of tabs for navigation within the activity. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 137 | * |
| 138 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 139 | * toolbar action bars. Consider using other |
| 140 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 141 | * navigation patterns</a> instead. |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 142 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 143 | @Deprecated |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 144 | public static final int NAVIGATION_MODE_TABS = 2; |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 145 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 146 | /** @hide */ |
| 147 | @Retention(RetentionPolicy.SOURCE) |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 148 | @IntDef(flag = true, prefix = { "DISPLAY_" }, value = { |
| 149 | DISPLAY_USE_LOGO, |
| 150 | DISPLAY_SHOW_HOME, |
| 151 | DISPLAY_HOME_AS_UP, |
| 152 | DISPLAY_SHOW_TITLE, |
| 153 | DISPLAY_SHOW_CUSTOM, |
| 154 | DISPLAY_TITLE_MULTIPLE_LINES |
| 155 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 156 | public @interface DisplayOptions {} |
| 157 | |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 158 | /** |
| 159 | * Use logo instead of icon if available. This flag will cause appropriate |
| 160 | * navigation modes to use a wider logo in place of the standard icon. |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 161 | * |
| 162 | * @see #setDisplayOptions(int) |
| 163 | * @see #setDisplayOptions(int, int) |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 164 | */ |
| 165 | public static final int DISPLAY_USE_LOGO = 0x1; |
| 166 | |
| 167 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 168 | * Show 'home' elements in this action bar, leaving more space for other |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 169 | * navigation elements. This includes logo and icon. |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 170 | * |
| 171 | * @see #setDisplayOptions(int) |
| 172 | * @see #setDisplayOptions(int, int) |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 173 | */ |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 174 | public static final int DISPLAY_SHOW_HOME = 0x2; |
| 175 | |
| 176 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 177 | * Display the 'home' element such that it appears as an 'up' affordance. |
| 178 | * e.g. show an arrow to the left indicating the action that will be taken. |
| 179 | * |
| 180 | * Set this flag if selecting the 'home' button in the action bar to return |
| 181 | * up by a single level in your UI rather than back to the top level or front page. |
| 182 | * |
Adam Powell | c29f4e5 | 2011-07-13 20:40:52 -0700 | [diff] [blame] | 183 | * <p>Setting this option will implicitly enable interaction with the home/up |
| 184 | * button. See {@link #setHomeButtonEnabled(boolean)}. |
| 185 | * |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 186 | * @see #setDisplayOptions(int) |
| 187 | * @see #setDisplayOptions(int, int) |
| 188 | */ |
| 189 | public static final int DISPLAY_HOME_AS_UP = 0x4; |
| 190 | |
| 191 | /** |
| 192 | * Show the activity title and subtitle, if present. |
| 193 | * |
| 194 | * @see #setTitle(CharSequence) |
| 195 | * @see #setTitle(int) |
| 196 | * @see #setSubtitle(CharSequence) |
| 197 | * @see #setSubtitle(int) |
| 198 | * @see #setDisplayOptions(int) |
| 199 | * @see #setDisplayOptions(int, int) |
| 200 | */ |
| 201 | public static final int DISPLAY_SHOW_TITLE = 0x8; |
| 202 | |
| 203 | /** |
| 204 | * Show the custom view if one has been set. |
| 205 | * @see #setCustomView(View) |
| 206 | * @see #setDisplayOptions(int) |
| 207 | * @see #setDisplayOptions(int, int) |
| 208 | */ |
| 209 | public static final int DISPLAY_SHOW_CUSTOM = 0x10; |
| 210 | |
| 211 | /** |
Adam Powell | 27cba38 | 2013-01-22 18:55:20 -0800 | [diff] [blame] | 212 | * Allow the title to wrap onto multiple lines if space is available |
| 213 | * @hide pending API approval |
| 214 | */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 215 | @UnsupportedAppUsage |
Adam Powell | 27cba38 | 2013-01-22 18:55:20 -0800 | [diff] [blame] | 216 | public static final int DISPLAY_TITLE_MULTIPLE_LINES = 0x20; |
| 217 | |
| 218 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 219 | * Set the action bar into custom navigation mode, supplying a view |
| 220 | * for custom navigation. |
| 221 | * |
| 222 | * Custom navigation views appear between the application icon and |
| 223 | * any action buttons and may use any space available there. Common |
| 224 | * use cases for custom navigation views might include an auto-suggesting |
| 225 | * address bar for a browser or other navigation mechanisms that do not |
| 226 | * translate well to provided navigation modes. |
| 227 | * |
| 228 | * @param view Custom navigation view to place in the ActionBar. |
| 229 | */ |
| 230 | public abstract void setCustomView(View view); |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 231 | |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 232 | /** |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 233 | * Set the action bar into custom navigation mode, supplying a view |
| 234 | * for custom navigation. |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 235 | * |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 236 | * <p>Custom navigation views appear between the application icon and |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 237 | * any action buttons and may use any space available there. Common |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 238 | * use cases for custom navigation views might include an auto-suggesting |
| 239 | * address bar for a browser or other navigation mechanisms that do not |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 240 | * translate well to provided navigation modes.</p> |
| 241 | * |
| 242 | * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for |
| 243 | * the custom view to be displayed.</p> |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 244 | * |
| 245 | * @param view Custom navigation view to place in the ActionBar. |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 246 | * @param layoutParams How this custom view should layout in the bar. |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 247 | * |
| 248 | * @see #setDisplayOptions(int, int) |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 249 | */ |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 250 | public abstract void setCustomView(View view, LayoutParams layoutParams); |
| 251 | |
| 252 | /** |
Adam Powell | 3f476b3 | 2011-01-03 19:25:36 -0800 | [diff] [blame] | 253 | * Set the action bar into custom navigation mode, supplying a view |
| 254 | * for custom navigation. |
| 255 | * |
| 256 | * <p>Custom navigation views appear between the application icon and |
| 257 | * any action buttons and may use any space available there. Common |
| 258 | * use cases for custom navigation views might include an auto-suggesting |
| 259 | * address bar for a browser or other navigation mechanisms that do not |
| 260 | * translate well to provided navigation modes.</p> |
| 261 | * |
| 262 | * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for |
| 263 | * the custom view to be displayed.</p> |
| 264 | * |
| 265 | * @param resId Resource ID of a layout to inflate into the ActionBar. |
| 266 | * |
| 267 | * @see #setDisplayOptions(int, int) |
| 268 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 269 | public abstract void setCustomView(@LayoutRes int resId); |
Adam Powell | 3f476b3 | 2011-01-03 19:25:36 -0800 | [diff] [blame] | 270 | |
| 271 | /** |
Adam Powell | 1969b87 | 2011-03-22 11:52:48 -0700 | [diff] [blame] | 272 | * Set the icon to display in the 'home' section of the action bar. |
| 273 | * The action bar will use an icon specified by its style or the |
| 274 | * activity icon by default. |
| 275 | * |
| 276 | * Whether the home section shows an icon or logo is controlled |
| 277 | * by the display option {@link #DISPLAY_USE_LOGO}. |
| 278 | * |
| 279 | * @param resId Resource ID of a drawable to show as an icon. |
| 280 | * |
| 281 | * @see #setDisplayUseLogoEnabled(boolean) |
| 282 | * @see #setDisplayShowHomeEnabled(boolean) |
| 283 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 284 | public abstract void setIcon(@DrawableRes int resId); |
Adam Powell | 1969b87 | 2011-03-22 11:52:48 -0700 | [diff] [blame] | 285 | |
| 286 | /** |
| 287 | * Set the icon to display in the 'home' section of the action bar. |
| 288 | * The action bar will use an icon specified by its style or the |
| 289 | * activity icon by default. |
| 290 | * |
| 291 | * Whether the home section shows an icon or logo is controlled |
| 292 | * by the display option {@link #DISPLAY_USE_LOGO}. |
| 293 | * |
| 294 | * @param icon Drawable to show as an icon. |
| 295 | * |
| 296 | * @see #setDisplayUseLogoEnabled(boolean) |
| 297 | * @see #setDisplayShowHomeEnabled(boolean) |
| 298 | */ |
| 299 | public abstract void setIcon(Drawable icon); |
| 300 | |
| 301 | /** |
| 302 | * Set the logo to display in the 'home' section of the action bar. |
| 303 | * The action bar will use a logo specified by its style or the |
| 304 | * activity logo by default. |
| 305 | * |
| 306 | * Whether the home section shows an icon or logo is controlled |
| 307 | * by the display option {@link #DISPLAY_USE_LOGO}. |
| 308 | * |
| 309 | * @param resId Resource ID of a drawable to show as a logo. |
| 310 | * |
| 311 | * @see #setDisplayUseLogoEnabled(boolean) |
| 312 | * @see #setDisplayShowHomeEnabled(boolean) |
| 313 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 314 | public abstract void setLogo(@DrawableRes int resId); |
Adam Powell | 1969b87 | 2011-03-22 11:52:48 -0700 | [diff] [blame] | 315 | |
| 316 | /** |
| 317 | * Set the logo to display in the 'home' section of the action bar. |
| 318 | * The action bar will use a logo specified by its style or the |
| 319 | * activity logo by default. |
| 320 | * |
| 321 | * Whether the home section shows an icon or logo is controlled |
| 322 | * by the display option {@link #DISPLAY_USE_LOGO}. |
| 323 | * |
| 324 | * @param logo Drawable to show as a logo. |
| 325 | * |
| 326 | * @see #setDisplayUseLogoEnabled(boolean) |
| 327 | * @see #setDisplayShowHomeEnabled(boolean) |
| 328 | */ |
| 329 | public abstract void setLogo(Drawable logo); |
| 330 | |
| 331 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 332 | * Set the adapter and navigation callback for list navigation mode. |
| 333 | * |
| 334 | * The supplied adapter will provide views for the expanded list as well as |
| 335 | * the currently selected item. (These may be displayed differently.) |
| 336 | * |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 337 | * The supplied OnNavigationListener will alert the application when the user |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 338 | * changes the current list selection. |
| 339 | * |
| 340 | * @param adapter An adapter that will provide views both to display |
| 341 | * the current navigation selection and populate views |
| 342 | * within the dropdown navigation menu. |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 343 | * @param callback An OnNavigationListener that will receive events when the user |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 344 | * selects a navigation item. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 345 | * |
| 346 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 347 | * toolbar action bars. Consider using other |
| 348 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 349 | * navigation patterns</a> instead. |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 350 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 351 | @Deprecated |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 352 | public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 353 | OnNavigationListener callback); |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 354 | |
| 355 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 356 | * Set the selected navigation item in list or tabbed navigation modes. |
Adam Powell | 1780977 | 2010-07-21 13:25:11 -0700 | [diff] [blame] | 357 | * |
| 358 | * @param position Position of the item to select. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 359 | * |
| 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 Powell | 1780977 | 2010-07-21 13:25:11 -0700 | [diff] [blame] | 364 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 365 | @Deprecated |
Adam Powell | 1780977 | 2010-07-21 13:25:11 -0700 | [diff] [blame] | 366 | public abstract void setSelectedNavigationItem(int position); |
| 367 | |
| 368 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 369 | * Get the position of the selected navigation item in list or tabbed navigation modes. |
| 370 | * |
| 371 | * @return Position of the selected item. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 372 | * |
| 373 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 374 | * toolbar action bars. Consider using other |
| 375 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 376 | * navigation patterns</a> instead. |
Adam Powell | 1780977 | 2010-07-21 13:25:11 -0700 | [diff] [blame] | 377 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 378 | @Deprecated |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 379 | public abstract int getSelectedNavigationIndex(); |
| 380 | |
| 381 | /** |
| 382 | * Get the number of navigation items present in the current navigation mode. |
| 383 | * |
| 384 | * @return Number of navigation items. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 385 | * |
| 386 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 387 | * toolbar action bars. Consider using other |
| 388 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 389 | * navigation patterns</a> instead. |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 390 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 391 | @Deprecated |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 392 | public abstract int getNavigationItemCount(); |
Adam Powell | 1780977 | 2010-07-21 13:25:11 -0700 | [diff] [blame] | 393 | |
| 394 | /** |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 395 | * Set the action bar's title. This will only be displayed if |
| 396 | * {@link #DISPLAY_SHOW_TITLE} is set. |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 397 | * |
| 398 | * @param title Title to set |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 399 | * |
| 400 | * @see #setTitle(int) |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 401 | * @see #setDisplayOptions(int, int) |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 402 | */ |
| 403 | public abstract void setTitle(CharSequence title); |
| 404 | |
| 405 | /** |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 406 | * Set the action bar's title. This will only be displayed if |
| 407 | * {@link #DISPLAY_SHOW_TITLE} is set. |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 408 | * |
| 409 | * @param resId Resource ID of title string to set |
| 410 | * |
| 411 | * @see #setTitle(CharSequence) |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 412 | * @see #setDisplayOptions(int, int) |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 413 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 414 | public abstract void setTitle(@StringRes int resId); |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 415 | |
| 416 | /** |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 417 | * Set the action bar's subtitle. This will only be displayed if |
| 418 | * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the |
| 419 | * subtitle entirely. |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 420 | * |
| 421 | * @param subtitle Subtitle to set |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 422 | * |
| 423 | * @see #setSubtitle(int) |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 424 | * @see #setDisplayOptions(int, int) |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 425 | */ |
| 426 | public abstract void setSubtitle(CharSequence subtitle); |
| 427 | |
| 428 | /** |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 429 | * Set the action bar's subtitle. This will only be displayed if |
| 430 | * {@link #DISPLAY_SHOW_TITLE} is set. |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 431 | * |
| 432 | * @param resId Resource ID of subtitle string to set |
| 433 | * |
| 434 | * @see #setSubtitle(CharSequence) |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 435 | * @see #setDisplayOptions(int, int) |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 436 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 437 | public abstract void setSubtitle(@StringRes int resId); |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 438 | |
| 439 | /** |
Adam Powell | a170078 | 2010-05-13 13:27:35 -0700 | [diff] [blame] | 440 | * Set display options. This changes all display option bits at once. To change |
| 441 | * a limited subset of display options, see {@link #setDisplayOptions(int, int)}. |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 442 | * |
| 443 | * @param options A combination of the bits defined by the DISPLAY_ constants |
| 444 | * defined in ActionBar. |
| 445 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 446 | public abstract void setDisplayOptions(@DisplayOptions int options); |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 447 | |
| 448 | /** |
Adam Powell | a170078 | 2010-05-13 13:27:35 -0700 | [diff] [blame] | 449 | * Set selected display options. Only the options specified by mask will be changed. |
| 450 | * To change all display option bits at once, see {@link #setDisplayOptions(int)}. |
| 451 | * |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 452 | * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the |
| 453 | * {@link #DISPLAY_SHOW_HOME} option. |
Ben Komalo | 5ad7af6 | 2010-11-01 12:04:51 -0700 | [diff] [blame] | 454 | * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 455 | * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}. |
Adam Powell | a170078 | 2010-05-13 13:27:35 -0700 | [diff] [blame] | 456 | * |
| 457 | * @param options A combination of the bits defined by the DISPLAY_ constants |
| 458 | * defined in ActionBar. |
| 459 | * @param mask A bit mask declaring which display options should be changed. |
| 460 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 461 | public abstract void setDisplayOptions(@DisplayOptions int options, @DisplayOptions int mask); |
Adam Powell | 3f476b3 | 2011-01-03 19:25:36 -0800 | [diff] [blame] | 462 | |
| 463 | /** |
| 464 | * Set whether to display the activity logo rather than the activity icon. |
| 465 | * A logo is often a wider, more detailed image. |
| 466 | * |
| 467 | * <p>To set several display options at once, see the setDisplayOptions methods. |
| 468 | * |
| 469 | * @param useLogo true to use the activity logo, false to use the activity icon. |
| 470 | * |
| 471 | * @see #setDisplayOptions(int) |
| 472 | * @see #setDisplayOptions(int, int) |
| 473 | */ |
| 474 | public abstract void setDisplayUseLogoEnabled(boolean useLogo); |
| 475 | |
| 476 | /** |
| 477 | * Set whether to include the application home affordance in the action bar. |
| 478 | * Home is presented as either an activity icon or logo. |
| 479 | * |
| 480 | * <p>To set several display options at once, see the setDisplayOptions methods. |
| 481 | * |
| 482 | * @param showHome true to show home, false otherwise. |
| 483 | * |
| 484 | * @see #setDisplayOptions(int) |
| 485 | * @see #setDisplayOptions(int, int) |
| 486 | */ |
| 487 | public abstract void setDisplayShowHomeEnabled(boolean showHome); |
| 488 | |
| 489 | /** |
| 490 | * Set whether home should be displayed as an "up" affordance. |
| 491 | * Set this to true if selecting "home" returns up by a single level in your UI |
| 492 | * rather than back to the top level or front page. |
| 493 | * |
| 494 | * <p>To set several display options at once, see the setDisplayOptions methods. |
| 495 | * |
| 496 | * @param showHomeAsUp true to show the user that selecting home will return one |
| 497 | * level up rather than to the top level of the app. |
| 498 | * |
| 499 | * @see #setDisplayOptions(int) |
| 500 | * @see #setDisplayOptions(int, int) |
| 501 | */ |
| 502 | public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp); |
| 503 | |
| 504 | /** |
| 505 | * Set whether an activity title/subtitle should be displayed. |
| 506 | * |
| 507 | * <p>To set several display options at once, see the setDisplayOptions methods. |
| 508 | * |
| 509 | * @param showTitle true to display a title/subtitle if present. |
| 510 | * |
| 511 | * @see #setDisplayOptions(int) |
| 512 | * @see #setDisplayOptions(int, int) |
| 513 | */ |
| 514 | public abstract void setDisplayShowTitleEnabled(boolean showTitle); |
| 515 | |
| 516 | /** |
| 517 | * Set whether a custom view should be displayed, if set. |
| 518 | * |
| 519 | * <p>To set several display options at once, see the setDisplayOptions methods. |
| 520 | * |
| 521 | * @param showCustom true if the currently set custom view should be displayed, false otherwise. |
| 522 | * |
| 523 | * @see #setDisplayOptions(int) |
| 524 | * @see #setDisplayOptions(int, int) |
| 525 | */ |
| 526 | public abstract void setDisplayShowCustomEnabled(boolean showCustom); |
| 527 | |
Adam Powell | a170078 | 2010-05-13 13:27:35 -0700 | [diff] [blame] | 528 | /** |
Adam Powell | f88b915 | 2011-09-07 14:54:32 -0700 | [diff] [blame] | 529 | * Set the ActionBar's background. This will be used for the primary |
| 530 | * action bar. |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 531 | * |
| 532 | * @param d Background drawable |
Adam Powell | f88b915 | 2011-09-07 14:54:32 -0700 | [diff] [blame] | 533 | * @see #setStackedBackgroundDrawable(Drawable) |
| 534 | * @see #setSplitBackgroundDrawable(Drawable) |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 535 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 536 | public abstract void setBackgroundDrawable(@Nullable Drawable d); |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 537 | |
| 538 | /** |
Adam Powell | f88b915 | 2011-09-07 14:54:32 -0700 | [diff] [blame] | 539 | * Set the ActionBar's stacked background. This will appear |
| 540 | * in the second row/stacked bar on some devices and configurations. |
| 541 | * |
| 542 | * @param d Background drawable for the stacked row |
| 543 | */ |
Adam Powell | 0145322 | 2011-09-07 16:13:36 -0700 | [diff] [blame] | 544 | public void setStackedBackgroundDrawable(Drawable d) { } |
Adam Powell | f88b915 | 2011-09-07 14:54:32 -0700 | [diff] [blame] | 545 | |
| 546 | /** |
| 547 | * Set the ActionBar's split background. This will appear in |
| 548 | * the split action bar containing menu-provided action buttons |
| 549 | * on some devices and configurations. |
Scott Main | e797ed6 | 2011-09-22 16:17:45 -0700 | [diff] [blame] | 550 | * <p>You can enable split action bar with {@link android.R.attr#uiOptions} |
Adam Powell | f88b915 | 2011-09-07 14:54:32 -0700 | [diff] [blame] | 551 | * |
| 552 | * @param d Background drawable for the split bar |
| 553 | */ |
Adam Powell | 0145322 | 2011-09-07 16:13:36 -0700 | [diff] [blame] | 554 | public void setSplitBackgroundDrawable(Drawable d) { } |
Adam Powell | f88b915 | 2011-09-07 14:54:32 -0700 | [diff] [blame] | 555 | |
| 556 | /** |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 557 | * @return The current custom view. |
| 558 | */ |
| 559 | public abstract View getCustomView(); |
| 560 | |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 561 | /** |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 562 | * Returns the current ActionBar title in standard mode. |
| 563 | * Returns null if {@link #getNavigationMode()} would not return |
| 564 | * {@link #NAVIGATION_MODE_STANDARD}. |
| 565 | * |
| 566 | * @return The current ActionBar title or null. |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 567 | */ |
| 568 | public abstract CharSequence getTitle(); |
| 569 | |
| 570 | /** |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 571 | * Returns the current ActionBar subtitle in standard mode. |
| 572 | * Returns null if {@link #getNavigationMode()} would not return |
| 573 | * {@link #NAVIGATION_MODE_STANDARD}. |
| 574 | * |
| 575 | * @return The current ActionBar subtitle or null. |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 576 | */ |
| 577 | public abstract CharSequence getSubtitle(); |
| 578 | |
| 579 | /** |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 580 | * Returns the current navigation mode. The result will be one of: |
| 581 | * <ul> |
| 582 | * <li>{@link #NAVIGATION_MODE_STANDARD}</li> |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 583 | * <li>{@link #NAVIGATION_MODE_LIST}</li> |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 584 | * <li>{@link #NAVIGATION_MODE_TABS}</li> |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 585 | * </ul> |
| 586 | * |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 587 | * @return The current navigation mode. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 588 | * |
| 589 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 590 | * toolbar action bars. Consider using other |
| 591 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 592 | * navigation patterns</a> instead. |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 593 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 594 | @Deprecated |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 595 | @NavigationMode |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 596 | public abstract int getNavigationMode(); |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 597 | |
| 598 | /** |
| 599 | * Set the current navigation mode. |
| 600 | * |
| 601 | * @param mode The new mode to set. |
| 602 | * @see #NAVIGATION_MODE_STANDARD |
| 603 | * @see #NAVIGATION_MODE_LIST |
| 604 | * @see #NAVIGATION_MODE_TABS |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 605 | * |
| 606 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 607 | * toolbar action bars. Consider using other |
| 608 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 609 | * navigation patterns</a> instead. |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 610 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 611 | @Deprecated |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 612 | public abstract void setNavigationMode(@NavigationMode int mode); |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 613 | |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 614 | /** |
| 615 | * @return The current set of display options. |
| 616 | */ |
| 617 | public abstract int getDisplayOptions(); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 618 | |
| 619 | /** |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 620 | * Create and return a new {@link Tab}. |
| 621 | * This tab will not be included in the action bar until it is added. |
| 622 | * |
Dianne Hackborn | 2f04883 | 2011-06-16 13:31:57 -0700 | [diff] [blame] | 623 | * <p>Very often tabs will be used to switch between {@link Fragment} |
| 624 | * objects. Here is a typical implementation of such tabs:</p> |
| 625 | * |
| 626 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java |
| 627 | * complete} |
| 628 | * |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 629 | * @return A new Tab |
| 630 | * |
| 631 | * @see #addTab(Tab) |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 632 | * |
| 633 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 634 | * toolbar action bars. Consider using other |
| 635 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 636 | * navigation patterns</a> instead. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 637 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 638 | @Deprecated |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 639 | public abstract Tab newTab(); |
| 640 | |
| 641 | /** |
| 642 | * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 643 | * If this is the first tab to be added it will become the selected tab. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 644 | * |
| 645 | * @param tab Tab to add |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 646 | * |
| 647 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 648 | * toolbar action bars. Consider using other |
| 649 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 650 | * navigation patterns</a> instead. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 651 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 652 | @Deprecated |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 653 | public abstract void addTab(Tab tab); |
| 654 | |
| 655 | /** |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 656 | * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. |
| 657 | * |
| 658 | * @param tab Tab to add |
| 659 | * @param setSelected True if the added tab should become the selected tab. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 660 | * |
| 661 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 662 | * toolbar action bars. Consider using other |
| 663 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 664 | * navigation patterns</a> instead. |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 665 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 666 | @Deprecated |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 667 | public abstract void addTab(Tab tab, boolean setSelected); |
| 668 | |
| 669 | /** |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 670 | * Add a tab for use in tabbed navigation mode. The tab will be inserted at |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 671 | * <code>position</code>. If this is the first tab to be added it will become |
| 672 | * the selected tab. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 673 | * |
| 674 | * @param tab The tab to add |
| 675 | * @param position The new position of the tab |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 676 | * |
| 677 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 678 | * toolbar action bars. Consider using other |
| 679 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 680 | * navigation patterns</a> instead. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 681 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 682 | @Deprecated |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 683 | public abstract void addTab(Tab tab, int position); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 684 | |
| 685 | /** |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 686 | * Add a tab for use in tabbed navigation mode. The tab will be insterted at |
| 687 | * <code>position</code>. |
| 688 | * |
| 689 | * @param tab The tab to add |
| 690 | * @param position The new position of the tab |
| 691 | * @param setSelected True if the added tab should become the selected tab. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 692 | * |
| 693 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 694 | * toolbar action bars. Consider using other |
| 695 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 696 | * navigation patterns</a> instead. |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 697 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 698 | @Deprecated |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 699 | public abstract void addTab(Tab tab, int position, boolean setSelected); |
| 700 | |
| 701 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 702 | * Remove a tab from the action bar. If the removed tab was selected it will be deselected |
| 703 | * and another tab will be selected if present. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 704 | * |
| 705 | * @param tab The tab to remove |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 706 | * |
| 707 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 708 | * toolbar action bars. Consider using other |
| 709 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 710 | * navigation patterns</a> instead. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 711 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 712 | @Deprecated |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 713 | public abstract void removeTab(Tab tab); |
| 714 | |
| 715 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 716 | * Remove a tab from the action bar. If the removed tab was selected it will be deselected |
| 717 | * and another tab will be selected if present. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 718 | * |
| 719 | * @param position Position of the tab to remove |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 720 | * |
| 721 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 722 | * toolbar action bars. Consider using other |
| 723 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 724 | * navigation patterns</a> instead. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 725 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 726 | @Deprecated |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 727 | public abstract void removeTabAt(int position); |
| 728 | |
| 729 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 730 | * Remove all tabs from the action bar and deselect the current tab. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 731 | * |
| 732 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 733 | * toolbar action bars. Consider using other |
| 734 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 735 | * navigation patterns</a> instead. |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 736 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 737 | @Deprecated |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 738 | public abstract void removeAllTabs(); |
| 739 | |
| 740 | /** |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 741 | * Select the specified tab. If it is not a child of this action bar it will be added. |
| 742 | * |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 743 | * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p> |
| 744 | * |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 745 | * @param tab Tab to select |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 746 | * |
| 747 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 748 | * toolbar action bars. Consider using other |
| 749 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 750 | * navigation patterns</a> instead. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 751 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 752 | @Deprecated |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 753 | public abstract void selectTab(Tab tab); |
| 754 | |
| 755 | /** |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 756 | * Returns the currently selected tab if in tabbed navigation mode and there is at least |
| 757 | * one tab present. |
| 758 | * |
| 759 | * @return The currently selected tab or null |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 760 | * |
| 761 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 762 | * toolbar action bars. Consider using other |
| 763 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 764 | * navigation patterns</a> instead. |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 765 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 766 | @Deprecated |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 767 | public abstract Tab getSelectedTab(); |
| 768 | |
| 769 | /** |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 770 | * Returns the tab at the specified index. |
| 771 | * |
| 772 | * @param index Index value in the range 0-get |
| 773 | * @return |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 774 | * |
| 775 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 776 | * toolbar action bars. Consider using other |
| 777 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 778 | * navigation patterns</a> instead. |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 779 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 780 | @Deprecated |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 781 | public abstract Tab getTabAt(int index); |
| 782 | |
| 783 | /** |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 784 | * Returns the number of tabs currently registered with the action bar. |
| 785 | * @return Tab count |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 786 | * |
| 787 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 788 | * toolbar action bars. Consider using other |
| 789 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 790 | * navigation patterns</a> instead. |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 791 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 792 | @Deprecated |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 793 | public abstract int getTabCount(); |
| 794 | |
| 795 | /** |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 796 | * Retrieve the current height of the ActionBar. |
| 797 | * |
| 798 | * @return The ActionBar's height |
| 799 | */ |
| 800 | public abstract int getHeight(); |
| 801 | |
| 802 | /** |
| 803 | * Show the ActionBar if it is not currently showing. |
| 804 | * If the window hosting the ActionBar does not have the feature |
| 805 | * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application |
| 806 | * content to fit the new space available. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 807 | * |
| 808 | * <p>If you are hiding the ActionBar through |
| 809 | * {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN}, |
| 810 | * you should not call this function directly. |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 811 | */ |
| 812 | public abstract void show(); |
| 813 | |
| 814 | /** |
Scott Main | e797ed6 | 2011-09-22 16:17:45 -0700 | [diff] [blame] | 815 | * Hide the ActionBar if it is currently showing. |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 816 | * If the window hosting the ActionBar does not have the feature |
| 817 | * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application |
| 818 | * content to fit the new space available. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 819 | * |
| 820 | * <p>Instead of calling this function directly, you can also cause an |
| 821 | * ActionBar using the overlay feature to hide through |
| 822 | * {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN}. |
| 823 | * Hiding the ActionBar through this system UI flag allows you to more |
| 824 | * seamlessly hide it in conjunction with other screen decorations. |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 825 | */ |
| 826 | public abstract void hide(); |
| 827 | |
| 828 | /** |
| 829 | * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise. |
| 830 | */ |
| 831 | public abstract boolean isShowing(); |
| 832 | |
| 833 | /** |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 834 | * Add a listener that will respond to menu visibility change events. |
| 835 | * |
| 836 | * @param listener The new listener to add |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 837 | */ |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 838 | public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener); |
| 839 | |
| 840 | /** |
| 841 | * Remove a menu visibility listener. This listener will no longer receive menu |
| 842 | * visibility change events. |
| 843 | * |
| 844 | * @param listener A listener to remove that was previously added |
| 845 | */ |
| 846 | public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener); |
| 847 | |
| 848 | /** |
Adam Powell | c29f4e5 | 2011-07-13 20:40:52 -0700 | [diff] [blame] | 849 | * Enable or disable the "home" button in the corner of the action bar. (Note that this |
| 850 | * is the application home/up affordance on the action bar, not the systemwide home |
| 851 | * button.) |
| 852 | * |
| 853 | * <p>This defaults to true for packages targeting < API 14. For packages targeting |
| 854 | * API 14 or greater, the application should call this method to enable interaction |
| 855 | * with the home/up affordance. |
| 856 | * |
| 857 | * <p>Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable |
| 858 | * the home button. |
| 859 | * |
| 860 | * @param enabled true to enable the home button, false to disable the home button. |
| 861 | */ |
Adam Powell | 88ab697 | 2011-07-28 11:25:01 -0700 | [diff] [blame] | 862 | public void setHomeButtonEnabled(boolean enabled) { } |
| 863 | |
| 864 | /** |
| 865 | * Returns a {@link Context} with an appropriate theme for creating views that |
| 866 | * will appear in the action bar. If you are inflating or instantiating custom views |
| 867 | * that will appear in an action bar, you should use the Context returned by this method. |
| 868 | * (This includes adapters used for list navigation mode.) |
| 869 | * This will ensure that views contrast properly against the action bar. |
| 870 | * |
| 871 | * @return A themed Context for creating views |
| 872 | */ |
| 873 | public Context getThemedContext() { return null; } |
Adam Powell | c29f4e5 | 2011-07-13 20:40:52 -0700 | [diff] [blame] | 874 | |
| 875 | /** |
Adam Powell | 27cba38 | 2013-01-22 18:55:20 -0800 | [diff] [blame] | 876 | * Returns true if the Title field has been truncated during layout for lack |
| 877 | * of available space. |
| 878 | * |
| 879 | * @return true if the Title field has been truncated |
| 880 | * @hide pending API approval |
| 881 | */ |
| 882 | public boolean isTitleTruncated() { return false; } |
| 883 | |
| 884 | /** |
Adam Powell | e0e2f4f | 2013-04-05 16:27:35 -0700 | [diff] [blame] | 885 | * Set an alternate drawable to display next to the icon/logo/title |
| 886 | * when {@link #DISPLAY_HOME_AS_UP} is enabled. This can be useful if you are using |
| 887 | * this mode to display an alternate selection for up navigation, such as a sliding drawer. |
| 888 | * |
| 889 | * <p>If you pass <code>null</code> to this method, the default drawable from the theme |
| 890 | * will be used.</p> |
| 891 | * |
| 892 | * <p>If you implement alternate or intermediate behavior around Up, you should also |
| 893 | * call {@link #setHomeActionContentDescription(int) setHomeActionContentDescription()} |
| 894 | * to provide a correct description of the action for accessibility support.</p> |
| 895 | * |
| 896 | * @param indicator A drawable to use for the up indicator, or null to use the theme's default |
| 897 | * |
| 898 | * @see #setDisplayOptions(int, int) |
| 899 | * @see #setDisplayHomeAsUpEnabled(boolean) |
| 900 | * @see #setHomeActionContentDescription(int) |
| 901 | */ |
| 902 | public void setHomeAsUpIndicator(Drawable indicator) { } |
| 903 | |
| 904 | /** |
| 905 | * Set an alternate drawable to display next to the icon/logo/title |
| 906 | * when {@link #DISPLAY_HOME_AS_UP} is enabled. This can be useful if you are using |
| 907 | * this mode to display an alternate selection for up navigation, such as a sliding drawer. |
| 908 | * |
| 909 | * <p>If you pass <code>0</code> to this method, the default drawable from the theme |
| 910 | * will be used.</p> |
| 911 | * |
| 912 | * <p>If you implement alternate or intermediate behavior around Up, you should also |
| 913 | * call {@link #setHomeActionContentDescription(int) setHomeActionContentDescription()} |
| 914 | * to provide a correct description of the action for accessibility support.</p> |
| 915 | * |
| 916 | * @param resId Resource ID of a drawable to use for the up indicator, or null |
| 917 | * to use the theme's default |
| 918 | * |
| 919 | * @see #setDisplayOptions(int, int) |
| 920 | * @see #setDisplayHomeAsUpEnabled(boolean) |
| 921 | * @see #setHomeActionContentDescription(int) |
| 922 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 923 | public void setHomeAsUpIndicator(@DrawableRes int resId) { } |
Adam Powell | e0e2f4f | 2013-04-05 16:27:35 -0700 | [diff] [blame] | 924 | |
| 925 | /** |
| 926 | * Set an alternate description for the Home/Up action, when enabled. |
| 927 | * |
| 928 | * <p>This description is commonly used for accessibility/screen readers when |
| 929 | * the Home action is enabled. (See {@link #setDisplayHomeAsUpEnabled(boolean)}.) |
| 930 | * Examples of this are, "Navigate Home" or "Navigate Up" depending on the |
| 931 | * {@link #DISPLAY_HOME_AS_UP} display option. If you have changed the home-as-up |
| 932 | * indicator using {@link #setHomeAsUpIndicator(int)} to indicate more specific |
| 933 | * functionality such as a sliding drawer, you should also set this to accurately |
| 934 | * describe the action.</p> |
| 935 | * |
| 936 | * <p>Setting this to <code>null</code> will use the system default description.</p> |
| 937 | * |
| 938 | * @param description New description for the Home action when enabled |
| 939 | * @see #setHomeAsUpIndicator(int) |
| 940 | * @see #setHomeAsUpIndicator(android.graphics.drawable.Drawable) |
| 941 | */ |
| 942 | public void setHomeActionContentDescription(CharSequence description) { } |
| 943 | |
| 944 | /** |
| 945 | * Set an alternate description for the Home/Up action, when enabled. |
| 946 | * |
| 947 | * <p>This description is commonly used for accessibility/screen readers when |
| 948 | * the Home action is enabled. (See {@link #setDisplayHomeAsUpEnabled(boolean)}.) |
| 949 | * Examples of this are, "Navigate Home" or "Navigate Up" depending on the |
| 950 | * {@link #DISPLAY_HOME_AS_UP} display option. If you have changed the home-as-up |
| 951 | * indicator using {@link #setHomeAsUpIndicator(int)} to indicate more specific |
| 952 | * functionality such as a sliding drawer, you should also set this to accurately |
| 953 | * describe the action.</p> |
| 954 | * |
| 955 | * <p>Setting this to <code>0</code> will use the system default description.</p> |
| 956 | * |
| 957 | * @param resId Resource ID of a string to use as the new description |
| 958 | * for the Home action when enabled |
| 959 | * @see #setHomeAsUpIndicator(int) |
| 960 | * @see #setHomeAsUpIndicator(android.graphics.drawable.Drawable) |
| 961 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 962 | public void setHomeActionContentDescription(@StringRes int resId) { } |
Adam Powell | e0e2f4f | 2013-04-05 16:27:35 -0700 | [diff] [blame] | 963 | |
Adam Powell | b36e4f9 | 2014-05-01 10:23:33 -0700 | [diff] [blame] | 964 | /** |
| 965 | * Enable hiding the action bar on content scroll. |
| 966 | * |
| 967 | * <p>If enabled, the action bar will scroll out of sight along with a |
| 968 | * {@link View#setNestedScrollingEnabled(boolean) nested scrolling child} view's content. |
| 969 | * The action bar must be in {@link Window#FEATURE_ACTION_BAR_OVERLAY overlay mode} |
| 970 | * to enable hiding on content scroll.</p> |
| 971 | * |
| 972 | * <p>When partially scrolled off screen the action bar is considered |
| 973 | * {@link #hide() hidden}. A call to {@link #show() show} will cause it to return to full view. |
| 974 | * </p> |
| 975 | * @param hideOnContentScroll true to enable hiding on content scroll. |
| 976 | */ |
| 977 | public void setHideOnContentScrollEnabled(boolean hideOnContentScroll) { |
| 978 | if (hideOnContentScroll) { |
| 979 | throw new UnsupportedOperationException("Hide on content scroll is not supported in " + |
| 980 | "this action bar configuration."); |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | /** |
| 985 | * Return whether the action bar is configured to scroll out of sight along with |
| 986 | * a {@link View#setNestedScrollingEnabled(boolean) nested scrolling child}. |
| 987 | * |
| 988 | * @return true if hide-on-content-scroll is enabled |
| 989 | * @see #setHideOnContentScrollEnabled(boolean) |
| 990 | */ |
| 991 | public boolean isHideOnContentScrollEnabled() { |
| 992 | return false; |
| 993 | } |
| 994 | |
| 995 | /** |
| 996 | * Return the current vertical offset of the action bar. |
| 997 | * |
| 998 | * <p>The action bar's current hide offset is the distance that the action bar is currently |
| 999 | * scrolled offscreen in pixels. The valid range is 0 (fully visible) to the action bar's |
| 1000 | * current measured {@link #getHeight() height} (fully invisible).</p> |
| 1001 | * |
| 1002 | * @return The action bar's offset toward its fully hidden state in pixels |
| 1003 | */ |
| 1004 | public int getHideOffset() { |
| 1005 | return 0; |
| 1006 | } |
| 1007 | |
| 1008 | /** |
| 1009 | * Set the current hide offset of the action bar. |
| 1010 | * |
| 1011 | * <p>The action bar's current hide offset is the distance that the action bar is currently |
| 1012 | * scrolled offscreen in pixels. The valid range is 0 (fully visible) to the action bar's |
| 1013 | * current measured {@link #getHeight() height} (fully invisible).</p> |
| 1014 | * |
| 1015 | * @param offset The action bar's offset toward its fully hidden state in pixels. |
| 1016 | */ |
| 1017 | public void setHideOffset(int offset) { |
| 1018 | if (offset != 0) { |
| 1019 | throw new UnsupportedOperationException("Setting an explicit action bar hide offset " + |
| 1020 | "is not supported in this action bar configuration."); |
| 1021 | } |
| 1022 | } |
| 1023 | |
Adam Powell | 14d1fa4 | 2014-07-10 16:23:39 -0700 | [diff] [blame] | 1024 | /** |
| 1025 | * Set the Z-axis elevation of the action bar in pixels. |
| 1026 | * |
| 1027 | * <p>The action bar's elevation is the distance it is placed from its parent surface. Higher |
| 1028 | * values are closer to the user.</p> |
| 1029 | * |
| 1030 | * @param elevation Elevation value in pixels |
| 1031 | */ |
| 1032 | public void setElevation(float elevation) { |
| 1033 | if (elevation != 0) { |
| 1034 | throw new UnsupportedOperationException("Setting a non-zero elevation is " + |
| 1035 | "not supported in this action bar configuration."); |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | /** |
| 1040 | * Get the Z-axis elevation of the action bar in pixels. |
| 1041 | * |
| 1042 | * <p>The action bar's elevation is the distance it is placed from its parent surface. Higher |
| 1043 | * values are closer to the user.</p> |
| 1044 | * |
| 1045 | * @return Elevation value in pixels |
| 1046 | */ |
| 1047 | public float getElevation() { |
| 1048 | return 0; |
| 1049 | } |
| 1050 | |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 1051 | /** @hide */ |
| 1052 | public void setDefaultDisplayHomeAsUpEnabled(boolean enabled) { |
| 1053 | } |
| 1054 | |
| 1055 | /** @hide */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 1056 | @UnsupportedAppUsage |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 1057 | public void setShowHideAnimationEnabled(boolean enabled) { |
| 1058 | } |
| 1059 | |
| 1060 | /** @hide */ |
| 1061 | public void onConfigurationChanged(Configuration config) { |
| 1062 | } |
| 1063 | |
| 1064 | /** @hide */ |
| 1065 | public void dispatchMenuVisibilityChanged(boolean visible) { |
| 1066 | } |
| 1067 | |
| 1068 | /** @hide */ |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 1069 | public ActionMode startActionMode(ActionMode.Callback callback) { |
| 1070 | return null; |
| 1071 | } |
| 1072 | |
Adam Powell | 07a7454 | 2014-05-30 15:52:44 -0700 | [diff] [blame] | 1073 | /** @hide */ |
| 1074 | public boolean openOptionsMenu() { |
| 1075 | return false; |
| 1076 | } |
| 1077 | |
| 1078 | /** @hide */ |
Evan Rosky | 41823d1 | 2017-03-21 14:42:35 -0700 | [diff] [blame] | 1079 | public boolean closeOptionsMenu() { |
| 1080 | return false; |
| 1081 | } |
| 1082 | |
| 1083 | /** @hide */ |
Adam Powell | 07a7454 | 2014-05-30 15:52:44 -0700 | [diff] [blame] | 1084 | public boolean invalidateOptionsMenu() { |
| 1085 | return false; |
| 1086 | } |
| 1087 | |
| 1088 | /** @hide */ |
| 1089 | public boolean onMenuKeyEvent(KeyEvent event) { |
| 1090 | return false; |
| 1091 | } |
| 1092 | |
| 1093 | /** @hide */ |
Abodunrinwa Toki | a04b7ad | 2015-06-30 17:44:04 -0700 | [diff] [blame] | 1094 | public boolean onKeyShortcut(int keyCode, KeyEvent event) { |
| 1095 | return false; |
| 1096 | } |
| 1097 | |
| 1098 | /** @hide */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 1099 | @UnsupportedAppUsage |
Adam Powell | 07a7454 | 2014-05-30 15:52:44 -0700 | [diff] [blame] | 1100 | public boolean collapseActionView() { |
| 1101 | return false; |
| 1102 | } |
| 1103 | |
Adam Powell | af2d859 | 2014-08-26 18:06:40 -0700 | [diff] [blame] | 1104 | /** @hide */ |
| 1105 | public void setWindowTitle(CharSequence title) { |
| 1106 | } |
| 1107 | |
Chris Banes | 21b2577 | 2016-01-04 20:41:59 +0000 | [diff] [blame] | 1108 | /** @hide */ |
| 1109 | public void onDestroy() { |
| 1110 | } |
| 1111 | |
George Mount | 5beb2617 | 2015-12-15 13:36:01 -0800 | [diff] [blame] | 1112 | /** |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 1113 | * Listener interface for ActionBar navigation events. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 1114 | * |
| 1115 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 1116 | * toolbar action bars. Consider using other |
| 1117 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 1118 | * navigation patterns</a> instead. |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 1119 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 1120 | @Deprecated |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 1121 | public interface OnNavigationListener { |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1122 | /** |
Adam Powell | a408291 | 2010-06-04 18:34:02 -0700 | [diff] [blame] | 1123 | * This method is called whenever a navigation item in your action bar |
| 1124 | * is selected. |
| 1125 | * |
| 1126 | * @param itemPosition Position of the item clicked. |
| 1127 | * @param itemId ID of the item clicked. |
| 1128 | * @return True if the event was handled, false otherwise. |
| 1129 | */ |
| 1130 | public boolean onNavigationItemSelected(int itemPosition, long itemId); |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1131 | } |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1132 | |
| 1133 | /** |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 1134 | * Listener for receiving events when action bar menus are shown or hidden. |
| 1135 | */ |
| 1136 | public interface OnMenuVisibilityListener { |
| 1137 | /** |
| 1138 | * Called when an action bar menu is shown or hidden. Applications may want to use |
| 1139 | * this to tune auto-hiding behavior for the action bar or pause/resume video playback, |
| 1140 | * gameplay, or other activity within the main content area. |
| 1141 | * |
| 1142 | * @param isVisible True if an action bar menu is now visible, false if no action bar |
| 1143 | * menus are visible. |
| 1144 | */ |
| 1145 | public void onMenuVisibilityChanged(boolean isVisible); |
| 1146 | } |
| 1147 | |
| 1148 | /** |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1149 | * A tab in the action bar. |
| 1150 | * |
| 1151 | * <p>Tabs manage the hiding and showing of {@link Fragment}s. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 1152 | * |
| 1153 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 1154 | * toolbar action bars. Consider using other |
| 1155 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 1156 | * navigation patterns</a> instead. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1157 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 1158 | @Deprecated |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1159 | public static abstract class Tab { |
| 1160 | /** |
| 1161 | * An invalid position for a tab. |
| 1162 | * |
| 1163 | * @see #getPosition() |
| 1164 | */ |
| 1165 | public static final int INVALID_POSITION = -1; |
| 1166 | |
| 1167 | /** |
| 1168 | * Return the current position of this tab in the action bar. |
| 1169 | * |
| 1170 | * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in |
| 1171 | * the action bar. |
| 1172 | */ |
| 1173 | public abstract int getPosition(); |
| 1174 | |
| 1175 | /** |
| 1176 | * Return the icon associated with this tab. |
| 1177 | * |
| 1178 | * @return The tab's icon |
| 1179 | */ |
| 1180 | public abstract Drawable getIcon(); |
| 1181 | |
| 1182 | /** |
| 1183 | * Return the text of this tab. |
| 1184 | * |
| 1185 | * @return The tab's text |
| 1186 | */ |
| 1187 | public abstract CharSequence getText(); |
| 1188 | |
| 1189 | /** |
| 1190 | * Set the icon displayed on this tab. |
| 1191 | * |
| 1192 | * @param icon The drawable to use as an icon |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1193 | * @return The current instance for call chaining |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1194 | */ |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1195 | public abstract Tab setIcon(Drawable icon); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1196 | |
| 1197 | /** |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1198 | * Set the icon displayed on this tab. |
| 1199 | * |
| 1200 | * @param resId Resource ID referring to the drawable to use as an icon |
| 1201 | * @return The current instance for call chaining |
| 1202 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1203 | public abstract Tab setIcon(@DrawableRes int resId); |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1204 | |
| 1205 | /** |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1206 | * Set the text displayed on this tab. Text may be truncated if there is not |
| 1207 | * room to display the entire string. |
| 1208 | * |
| 1209 | * @param text The text to display |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1210 | * @return The current instance for call chaining |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1211 | */ |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1212 | public abstract Tab setText(CharSequence text); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1213 | |
| 1214 | /** |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1215 | * Set the text displayed on this tab. Text may be truncated if there is not |
| 1216 | * room to display the entire string. |
| 1217 | * |
| 1218 | * @param resId A resource ID referring to the text that should be displayed |
| 1219 | * @return The current instance for call chaining |
| 1220 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1221 | public abstract Tab setText(@StringRes int resId); |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1222 | |
| 1223 | /** |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1224 | * Set a custom view to be used for this tab. This overrides values set by |
| 1225 | * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1226 | * |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1227 | * @param view Custom view to be used as a tab. |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1228 | * @return The current instance for call chaining |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1229 | */ |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1230 | public abstract Tab setCustomView(View view); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1231 | |
| 1232 | /** |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1233 | * Set a custom view to be used for this tab. This overrides values set by |
| 1234 | * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. |
| 1235 | * |
| 1236 | * @param layoutResId A layout resource to inflate and use as a custom tab view |
| 1237 | * @return The current instance for call chaining |
| 1238 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1239 | public abstract Tab setCustomView(@LayoutRes int layoutResId); |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1240 | |
| 1241 | /** |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1242 | * Retrieve a previously set custom view for this tab. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1243 | * |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1244 | * @return The custom view set by {@link #setCustomView(View)}. |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1245 | */ |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1246 | public abstract View getCustomView(); |
| 1247 | |
| 1248 | /** |
| 1249 | * Give this Tab an arbitrary object to hold for later use. |
| 1250 | * |
| 1251 | * @param obj Object to store |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1252 | * @return The current instance for call chaining |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1253 | */ |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1254 | public abstract Tab setTag(Object obj); |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1255 | |
| 1256 | /** |
| 1257 | * @return This Tab's tag object. |
| 1258 | */ |
| 1259 | public abstract Object getTag(); |
| 1260 | |
| 1261 | /** |
| 1262 | * Set the {@link TabListener} that will handle switching to and from this tab. |
| 1263 | * All tabs must have a TabListener set before being added to the ActionBar. |
| 1264 | * |
| 1265 | * @param listener Listener to handle tab selection events |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1266 | * @return The current instance for call chaining |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1267 | */ |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1268 | public abstract Tab setTabListener(TabListener listener); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1269 | |
| 1270 | /** |
| 1271 | * Select this tab. Only valid if the tab has been added to the action bar. |
| 1272 | */ |
| 1273 | public abstract void select(); |
Adam Powell | 94e56ef | 2011-09-06 21:22:22 -0700 | [diff] [blame] | 1274 | |
| 1275 | /** |
| 1276 | * Set a description of this tab's content for use in accessibility support. |
| 1277 | * If no content description is provided the title will be used. |
| 1278 | * |
| 1279 | * @param resId A resource ID referring to the description text |
| 1280 | * @return The current instance for call chaining |
| 1281 | * @see #setContentDescription(CharSequence) |
| 1282 | * @see #getContentDescription() |
| 1283 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1284 | public abstract Tab setContentDescription(@StringRes int resId); |
Adam Powell | 94e56ef | 2011-09-06 21:22:22 -0700 | [diff] [blame] | 1285 | |
| 1286 | /** |
| 1287 | * Set a description of this tab's content for use in accessibility support. |
| 1288 | * If no content description is provided the title will be used. |
| 1289 | * |
| 1290 | * @param contentDesc Description of this tab's content |
| 1291 | * @return The current instance for call chaining |
| 1292 | * @see #setContentDescription(int) |
| 1293 | * @see #getContentDescription() |
| 1294 | */ |
| 1295 | public abstract Tab setContentDescription(CharSequence contentDesc); |
| 1296 | |
| 1297 | /** |
| 1298 | * Gets a brief description of this tab's content for use in accessibility support. |
| 1299 | * |
| 1300 | * @return Description of this tab's content |
| 1301 | * @see #setContentDescription(CharSequence) |
| 1302 | * @see #setContentDescription(int) |
| 1303 | */ |
| 1304 | public abstract CharSequence getContentDescription(); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1305 | } |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1306 | |
| 1307 | /** |
| 1308 | * Callback interface invoked when a tab is focused, unfocused, added, or removed. |
Adam Powell | fc35dfd | 2014-03-17 17:44:59 -0700 | [diff] [blame] | 1309 | * |
| 1310 | * @deprecated Action bar navigation modes are deprecated and not supported by inline |
| 1311 | * toolbar action bars. Consider using other |
| 1312 | * <a href="http://developer.android.com/design/patterns/navigation.html">common |
| 1313 | * navigation patterns</a> instead. |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1314 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 1315 | @Deprecated |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1316 | public interface TabListener { |
| 1317 | /** |
| 1318 | * Called when a tab enters the selected state. |
| 1319 | * |
| 1320 | * @param tab The tab that was selected |
| 1321 | * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute |
| 1322 | * during a tab switch. The previous tab's unselect and this tab's select will be |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1323 | * executed in a single transaction. This FragmentTransaction does not support |
| 1324 | * being added to the back stack. |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1325 | */ |
| 1326 | public void onTabSelected(Tab tab, FragmentTransaction ft); |
| 1327 | |
| 1328 | /** |
| 1329 | * Called when a tab exits the selected state. |
| 1330 | * |
| 1331 | * @param tab The tab that was unselected |
| 1332 | * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute |
| 1333 | * during a tab switch. This tab's unselect and the newly selected tab's select |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1334 | * will be executed in a single transaction. This FragmentTransaction does not |
| 1335 | * support being added to the back stack. |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1336 | */ |
| 1337 | public void onTabUnselected(Tab tab, FragmentTransaction ft); |
Adam Powell | 7f9b905 | 2010-10-19 16:56:07 -0700 | [diff] [blame] | 1338 | |
| 1339 | /** |
| 1340 | * Called when a tab that is already selected is chosen again by the user. |
| 1341 | * Some applications may use this action to return to the top level of a category. |
| 1342 | * |
| 1343 | * @param tab The tab that was reselected. |
| 1344 | * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1345 | * once this method returns. This FragmentTransaction does not support |
| 1346 | * being added to the back stack. |
Adam Powell | 7f9b905 | 2010-10-19 16:56:07 -0700 | [diff] [blame] | 1347 | */ |
| 1348 | public void onTabReselected(Tab tab, FragmentTransaction ft); |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1349 | } |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1350 | |
| 1351 | /** |
| 1352 | * Per-child layout information associated with action bar custom views. |
| 1353 | * |
| 1354 | * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity |
| 1355 | */ |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 1356 | public static class LayoutParams extends ViewGroup.MarginLayoutParams { |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1357 | /** |
| 1358 | * Gravity for the view associated with these LayoutParams. |
| 1359 | * |
| 1360 | * @see android.view.Gravity |
| 1361 | */ |
| 1362 | @ViewDebug.ExportedProperty(category = "layout", mapping = { |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 1363 | @ViewDebug.IntToString(from = -1, to = "NONE"), |
| 1364 | @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"), |
| 1365 | @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"), |
| 1366 | @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"), |
| 1367 | @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"), |
| 1368 | @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"), |
| 1369 | @ViewDebug.IntToString(from = Gravity.START, to = "START"), |
| 1370 | @ViewDebug.IntToString(from = Gravity.END, to = "END"), |
| 1371 | @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"), |
| 1372 | @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"), |
| 1373 | @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"), |
| 1374 | @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"), |
| 1375 | @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"), |
| 1376 | @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL") |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1377 | }) |
Ashley Rose | de3b4a7 | 2019-03-04 16:44:07 -0500 | [diff] [blame] | 1378 | @InspectableProperty( |
| 1379 | name = "layout_gravity", |
| 1380 | valueType = InspectableProperty.ValueType.GRAVITY) |
Fabrice Di Meglio | cf1ba02 | 2012-06-25 15:49:11 -0700 | [diff] [blame] | 1381 | public int gravity = Gravity.NO_GRAVITY; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1382 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1383 | public LayoutParams(@NonNull Context c, AttributeSet attrs) { |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1384 | super(c, attrs); |
Adam Powell | b226bea | 2014-04-04 12:23:42 -0700 | [diff] [blame] | 1385 | |
| 1386 | TypedArray a = c.obtainStyledAttributes(attrs, |
| 1387 | com.android.internal.R.styleable.ActionBar_LayoutParams); |
| 1388 | gravity = a.getInt( |
| 1389 | com.android.internal.R.styleable.ActionBar_LayoutParams_layout_gravity, |
| 1390 | Gravity.NO_GRAVITY); |
| 1391 | a.recycle(); |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1392 | } |
| 1393 | |
| 1394 | public LayoutParams(int width, int height) { |
| 1395 | super(width, height); |
Adam Powell | e021e6e | 2014-05-23 17:27:24 -0700 | [diff] [blame] | 1396 | this.gravity = Gravity.CENTER_VERTICAL | Gravity.START; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | public LayoutParams(int width, int height, int gravity) { |
| 1400 | super(width, height); |
Alan Viverette | da4bd6f | 2014-04-14 12:58:34 -0700 | [diff] [blame] | 1401 | |
| 1402 | this.gravity = gravity; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1403 | } |
| 1404 | |
| 1405 | public LayoutParams(int gravity) { |
| 1406 | this(WRAP_CONTENT, MATCH_PARENT, gravity); |
| 1407 | } |
| 1408 | |
| 1409 | public LayoutParams(LayoutParams source) { |
| 1410 | super(source); |
Adam Powell | e021e6e | 2014-05-23 17:27:24 -0700 | [diff] [blame] | 1411 | this.gravity = source.gravity; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1412 | } |
| 1413 | |
| 1414 | public LayoutParams(ViewGroup.LayoutParams source) { |
| 1415 | super(source); |
| 1416 | } |
Adam Powell | e43340c | 2014-03-17 19:10:43 -0700 | [diff] [blame] | 1417 | |
Adam Powell | d760083 | 2014-07-01 15:22:50 -0700 | [diff] [blame] | 1418 | /* |
| 1419 | * Note for framework developers: |
| 1420 | * |
| 1421 | * You might notice that ActionBar.LayoutParams is missing a constructor overload |
| 1422 | * for MarginLayoutParams. While it may seem like a good idea to add one, at this |
| 1423 | * point it's dangerous for source compatibility. Upon building against a new |
| 1424 | * version of the SDK an app can end up statically linking to the new MarginLayoutParams |
| 1425 | * overload, causing a crash when running on older platform versions with no other changes. |
| 1426 | */ |
Siva Velusamy | 94a6d15 | 2015-05-05 15:07:00 -0700 | [diff] [blame] | 1427 | |
| 1428 | /** @hide */ |
| 1429 | @Override |
| 1430 | protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { |
| 1431 | super.encodeProperties(encoder); |
| 1432 | |
| 1433 | encoder.addProperty("gravity", gravity); |
| 1434 | } |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1435 | } |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1436 | } |