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