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