ActionBar.java revision c29f4e52c3377924df26910cce3ff26278d1f484
133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell/* 233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Copyright (C) 2010 The Android Open Source Project 333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Licensed under the Apache License, Version 2.0 (the "License"); 533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * you may not use this file except in compliance with the License. 633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * You may obtain a copy of the License at 733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * http://www.apache.org/licenses/LICENSE-2.0 933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 1033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Unless required by applicable law or agreed to in writing, software 1133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * distributed under the License is distributed on an "AS IS" BASIS, 1233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * See the License for the specific language governing permissions and 1433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * limitations under the License. 1533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 1733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellpackage android.app; 1833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 199ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.content.Context; 209ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.content.res.TypedArray; 2133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellimport android.graphics.drawable.Drawable; 229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.util.AttributeSet; 239ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.view.Gravity; 2433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellimport android.view.View; 259ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.view.ViewDebug; 269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.view.ViewGroup; 279ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.view.ViewGroup.MarginLayoutParams; 286b336f835d637853800b94689375a03f337139a4Adam Powellimport android.view.Window; 29a408291e22def5755559f42cde913706a6d628c0Adam Powellimport android.widget.SpinnerAdapter; 3033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 3133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell/** 3233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * This is the public interface to the contextual ActionBar. 3333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * The ActionBar acts as a replacement for the title bar in Activities. 3433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * It provides facilities for creating toolbar actions as well as 3533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * methods of navigating around an application. 3633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 3733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellpublic abstract class ActionBar { 38a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell /** 39a408291e22def5755559f42cde913706a6d628c0Adam Powell * Standard navigation mode. Consists of either a logo or icon 40a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * and title text with an optional subtitle. Clicking any of these elements 41cf0357639e952a87f0d535c82691919af81f058bAdam Powell * will dispatch onOptionsItemSelected to the host Activity with 42a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * a MenuItem with item ID android.R.id.home. 43a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell */ 44a408291e22def5755559f42cde913706a6d628c0Adam Powell public static final int NAVIGATION_MODE_STANDARD = 0; 4533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 4633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 479ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * List navigation mode. Instead of static title text this mode 489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * presents a list menu for navigation within the activity. 499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * e.g. this might be presented to the user as a dropdown list. 5033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int NAVIGATION_MODE_LIST = 1; 5233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 5333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 5433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Tab navigation mode. Instead of static title text this mode 5533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * presents a series of tabs for navigation within the activity. 5633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 5733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int NAVIGATION_MODE_TABS = 2; 5833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 5933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 6033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Use logo instead of icon if available. This flag will cause appropriate 6133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * navigation modes to use a wider logo in place of the standard icon. 629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 6533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 6633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int DISPLAY_USE_LOGO = 0x1; 6733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 6833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Show 'home' elements in this action bar, leaving more space for other 7033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * navigation elements. This includes logo and icon. 719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 759ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_SHOW_HOME = 0x2; 769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Display the 'home' element such that it appears as an 'up' affordance. 799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * e.g. show an arrow to the left indicating the action that will be taken. 809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set this flag if selecting the 'home' button in the action bar to return 829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * up by a single level in your UI rather than back to the top level or front page. 839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 84c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * <p>Setting this option will implicitly enable interaction with the home/up 85c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * button. See {@link #setHomeButtonEnabled(boolean)}. 86c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * 879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 909ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_HOME_AS_UP = 0x4; 919ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Show the activity title and subtitle, if present. 949ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setTitle(CharSequence) 969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setTitle(int) 979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setSubtitle(CharSequence) 989ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setSubtitle(int) 999ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 1009ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 1019ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1029ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_SHOW_TITLE = 0x8; 1039ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1049ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1059ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Show the custom view if one has been set. 1069ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setCustomView(View) 1079ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 1089ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 1099ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1109ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_SHOW_CUSTOM = 0x10; 1119ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1129ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1139ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the action bar into custom navigation mode, supplying a view 1149ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * for custom navigation. 1159ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1169ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Custom navigation views appear between the application icon and 1179ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * any action buttons and may use any space available there. Common 1189ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * use cases for custom navigation views might include an auto-suggesting 1199ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * address bar for a browser or other navigation mechanisms that do not 1209ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * translate well to provided navigation modes. 1219ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param view Custom navigation view to place in the ActionBar. 12333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1249ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setCustomView(View view); 12589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 12633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 127a408291e22def5755559f42cde913706a6d628c0Adam Powell * Set the action bar into custom navigation mode, supplying a view 128a408291e22def5755559f42cde913706a6d628c0Adam Powell * for custom navigation. 12933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 130ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * <p>Custom navigation views appear between the application icon and 13133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * any action buttons and may use any space available there. Common 132a408291e22def5755559f42cde913706a6d628c0Adam Powell * use cases for custom navigation views might include an auto-suggesting 133a408291e22def5755559f42cde913706a6d628c0Adam Powell * address bar for a browser or other navigation mechanisms that do not 134ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * translate well to provided navigation modes.</p> 135ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * 136ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for 137ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * the custom view to be displayed.</p> 13833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 13933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param view Custom navigation view to place in the ActionBar. 1409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param layoutParams How this custom view should layout in the bar. 141ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * 142ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 14333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1449ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setCustomView(View view, LayoutParams layoutParams); 1459ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1473f476b34049d062942eafcf48396f593e00bd324Adam Powell * Set the action bar into custom navigation mode, supplying a view 1483f476b34049d062942eafcf48396f593e00bd324Adam Powell * for custom navigation. 1493f476b34049d062942eafcf48396f593e00bd324Adam Powell * 1503f476b34049d062942eafcf48396f593e00bd324Adam Powell * <p>Custom navigation views appear between the application icon and 1513f476b34049d062942eafcf48396f593e00bd324Adam Powell * any action buttons and may use any space available there. Common 1523f476b34049d062942eafcf48396f593e00bd324Adam Powell * use cases for custom navigation views might include an auto-suggesting 1533f476b34049d062942eafcf48396f593e00bd324Adam Powell * address bar for a browser or other navigation mechanisms that do not 1543f476b34049d062942eafcf48396f593e00bd324Adam Powell * translate well to provided navigation modes.</p> 1553f476b34049d062942eafcf48396f593e00bd324Adam Powell * 1563f476b34049d062942eafcf48396f593e00bd324Adam Powell * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for 1573f476b34049d062942eafcf48396f593e00bd324Adam Powell * the custom view to be displayed.</p> 1583f476b34049d062942eafcf48396f593e00bd324Adam Powell * 1593f476b34049d062942eafcf48396f593e00bd324Adam Powell * @param resId Resource ID of a layout to inflate into the ActionBar. 1603f476b34049d062942eafcf48396f593e00bd324Adam Powell * 1613f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int, int) 1623f476b34049d062942eafcf48396f593e00bd324Adam Powell */ 1633f476b34049d062942eafcf48396f593e00bd324Adam Powell public abstract void setCustomView(int resId); 1643f476b34049d062942eafcf48396f593e00bd324Adam Powell 1653f476b34049d062942eafcf48396f593e00bd324Adam Powell /** 1661969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * Set the icon to display in the 'home' section of the action bar. 1671969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * The action bar will use an icon specified by its style or the 1681969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * activity icon by default. 1691969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 1701969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * Whether the home section shows an icon or logo is controlled 1711969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * by the display option {@link #DISPLAY_USE_LOGO}. 1721969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 1731969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @param resId Resource ID of a drawable to show as an icon. 1741969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 1751969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @see #setDisplayUseLogoEnabled(boolean) 1761969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @see #setDisplayShowHomeEnabled(boolean) 1771969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell */ 1781969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell public abstract void setIcon(int resId); 1791969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell 1801969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell /** 1811969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * Set the icon to display in the 'home' section of the action bar. 1821969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * The action bar will use an icon specified by its style or the 1831969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * activity icon by default. 1841969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 1851969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * Whether the home section shows an icon or logo is controlled 1861969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * by the display option {@link #DISPLAY_USE_LOGO}. 1871969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 1881969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @param icon Drawable to show as an icon. 1891969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 1901969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @see #setDisplayUseLogoEnabled(boolean) 1911969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @see #setDisplayShowHomeEnabled(boolean) 1921969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell */ 1931969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell public abstract void setIcon(Drawable icon); 1941969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell 1951969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell /** 1961969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * Set the logo to display in the 'home' section of the action bar. 1971969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * The action bar will use a logo specified by its style or the 1981969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * activity logo by default. 1991969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 2001969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * Whether the home section shows an icon or logo is controlled 2011969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * by the display option {@link #DISPLAY_USE_LOGO}. 2021969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 2031969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @param resId Resource ID of a drawable to show as a logo. 2041969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 2051969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @see #setDisplayUseLogoEnabled(boolean) 2061969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @see #setDisplayShowHomeEnabled(boolean) 2071969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell */ 2081969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell public abstract void setLogo(int resId); 2091969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell 2101969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell /** 2111969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * Set the logo to display in the 'home' section of the action bar. 2121969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * The action bar will use a logo specified by its style or the 2131969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * activity logo by default. 2141969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 2151969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * Whether the home section shows an icon or logo is controlled 2161969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * by the display option {@link #DISPLAY_USE_LOGO}. 2171969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 2181969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @param logo Drawable to show as a logo. 2191969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * 2201969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @see #setDisplayUseLogoEnabled(boolean) 2211969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell * @see #setDisplayShowHomeEnabled(boolean) 2221969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell */ 2231969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell public abstract void setLogo(Drawable logo); 2241969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell 2251969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell /** 2269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the adapter and navigation callback for list navigation mode. 2279ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 2289ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * The supplied adapter will provide views for the expanded list as well as 2299ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * the currently selected item. (These may be displayed differently.) 2309ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 2318515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * The supplied OnNavigationListener will alert the application when the user 2329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * changes the current list selection. 2339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 2349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param adapter An adapter that will provide views both to display 2359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * the current navigation selection and populate views 2369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * within the dropdown navigation menu. 2378515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param callback An OnNavigationListener that will receive events when the user 2389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * selects a navigation item. 2399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 2409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, 2418515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell OnNavigationListener callback); 2429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 2439ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 2449ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the selected navigation item in list or tabbed navigation modes. 245178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * 246178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @param position Position of the item to select. 247178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell */ 248178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell public abstract void setSelectedNavigationItem(int position); 249178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell 250178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell /** 2519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Get the position of the selected navigation item in list or tabbed navigation modes. 252178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * 253178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @return Position of the selected item. 2549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 2559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract int getSelectedNavigationIndex(); 2569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 2579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 2589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Get the number of navigation items present in the current navigation mode. 2599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 2609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return Number of navigation items. 2619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 2629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract int getNavigationItemCount(); 2639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 2649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 265ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's title. This will only be displayed if 266ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. 2670e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 2680e94b5151d817e600a888448a662208b29b5ef46Adam Powell * @param title Title to set 269a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 270a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setTitle(int) 271ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 2720e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 2730e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setTitle(CharSequence title); 2740e94b5151d817e600a888448a662208b29b5ef46Adam Powell 2750e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 276ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's title. This will only be displayed if 277ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. 278a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 279a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @param resId Resource ID of title string to set 280a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 281a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setTitle(CharSequence) 282ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 283a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell */ 284a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell public abstract void setTitle(int resId); 285a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell 286a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell /** 287ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's subtitle. This will only be displayed if 288ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the 289ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * subtitle entirely. 2900e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 2910e94b5151d817e600a888448a662208b29b5ef46Adam Powell * @param subtitle Subtitle to set 292a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 293a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setSubtitle(int) 294ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 2950e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 2960e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setSubtitle(CharSequence subtitle); 2970e94b5151d817e600a888448a662208b29b5ef46Adam Powell 2980e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 299ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's subtitle. This will only be displayed if 300ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. 301a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 302a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @param resId Resource ID of subtitle string to set 303a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 304a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setSubtitle(CharSequence) 305ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 306a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell */ 307a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell public abstract void setSubtitle(int resId); 308a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell 309a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell /** 310a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * Set display options. This changes all display option bits at once. To change 311a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * a limited subset of display options, see {@link #setDisplayOptions(int, int)}. 31233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 31333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param options A combination of the bits defined by the DISPLAY_ constants 31433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * defined in ActionBar. 31533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 31633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract void setDisplayOptions(int options); 31733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 31833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 319a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * Set selected display options. Only the options specified by mask will be changed. 320a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * To change all display option bits at once, see {@link #setDisplayOptions(int)}. 321a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * 3229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the 3239ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * {@link #DISPLAY_SHOW_HOME} option. 3245ad7af6fc764f71765b134b8cd51787a7e78753aBen Komalo * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) 3259ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}. 326a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * 327a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * @param options A combination of the bits defined by the DISPLAY_ constants 328a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * defined in ActionBar. 329a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * @param mask A bit mask declaring which display options should be changed. 330a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell */ 331a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell public abstract void setDisplayOptions(int options, int mask); 3323f476b34049d062942eafcf48396f593e00bd324Adam Powell 3333f476b34049d062942eafcf48396f593e00bd324Adam Powell /** 3343f476b34049d062942eafcf48396f593e00bd324Adam Powell * Set whether to display the activity logo rather than the activity icon. 3353f476b34049d062942eafcf48396f593e00bd324Adam Powell * A logo is often a wider, more detailed image. 3363f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3373f476b34049d062942eafcf48396f593e00bd324Adam Powell * <p>To set several display options at once, see the setDisplayOptions methods. 3383f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3393f476b34049d062942eafcf48396f593e00bd324Adam Powell * @param useLogo true to use the activity logo, false to use the activity icon. 3403f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3413f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int) 3423f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int, int) 3433f476b34049d062942eafcf48396f593e00bd324Adam Powell */ 3443f476b34049d062942eafcf48396f593e00bd324Adam Powell public abstract void setDisplayUseLogoEnabled(boolean useLogo); 3453f476b34049d062942eafcf48396f593e00bd324Adam Powell 3463f476b34049d062942eafcf48396f593e00bd324Adam Powell /** 3473f476b34049d062942eafcf48396f593e00bd324Adam Powell * Set whether to include the application home affordance in the action bar. 3483f476b34049d062942eafcf48396f593e00bd324Adam Powell * Home is presented as either an activity icon or logo. 3493f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3503f476b34049d062942eafcf48396f593e00bd324Adam Powell * <p>To set several display options at once, see the setDisplayOptions methods. 3513f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3523f476b34049d062942eafcf48396f593e00bd324Adam Powell * @param showHome true to show home, false otherwise. 3533f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3543f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int) 3553f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int, int) 3563f476b34049d062942eafcf48396f593e00bd324Adam Powell */ 3573f476b34049d062942eafcf48396f593e00bd324Adam Powell public abstract void setDisplayShowHomeEnabled(boolean showHome); 3583f476b34049d062942eafcf48396f593e00bd324Adam Powell 3593f476b34049d062942eafcf48396f593e00bd324Adam Powell /** 3603f476b34049d062942eafcf48396f593e00bd324Adam Powell * Set whether home should be displayed as an "up" affordance. 3613f476b34049d062942eafcf48396f593e00bd324Adam Powell * Set this to true if selecting "home" returns up by a single level in your UI 3623f476b34049d062942eafcf48396f593e00bd324Adam Powell * rather than back to the top level or front page. 3633f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3643f476b34049d062942eafcf48396f593e00bd324Adam Powell * <p>To set several display options at once, see the setDisplayOptions methods. 3653f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3663f476b34049d062942eafcf48396f593e00bd324Adam Powell * @param showHomeAsUp true to show the user that selecting home will return one 3673f476b34049d062942eafcf48396f593e00bd324Adam Powell * level up rather than to the top level of the app. 3683f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3693f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int) 3703f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int, int) 3713f476b34049d062942eafcf48396f593e00bd324Adam Powell */ 3723f476b34049d062942eafcf48396f593e00bd324Adam Powell public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp); 3733f476b34049d062942eafcf48396f593e00bd324Adam Powell 3743f476b34049d062942eafcf48396f593e00bd324Adam Powell /** 3753f476b34049d062942eafcf48396f593e00bd324Adam Powell * Set whether an activity title/subtitle should be displayed. 3763f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3773f476b34049d062942eafcf48396f593e00bd324Adam Powell * <p>To set several display options at once, see the setDisplayOptions methods. 3783f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3793f476b34049d062942eafcf48396f593e00bd324Adam Powell * @param showTitle true to display a title/subtitle if present. 3803f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3813f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int) 3823f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int, int) 3833f476b34049d062942eafcf48396f593e00bd324Adam Powell */ 3843f476b34049d062942eafcf48396f593e00bd324Adam Powell public abstract void setDisplayShowTitleEnabled(boolean showTitle); 3853f476b34049d062942eafcf48396f593e00bd324Adam Powell 3863f476b34049d062942eafcf48396f593e00bd324Adam Powell /** 3873f476b34049d062942eafcf48396f593e00bd324Adam Powell * Set whether a custom view should be displayed, if set. 3883f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3893f476b34049d062942eafcf48396f593e00bd324Adam Powell * <p>To set several display options at once, see the setDisplayOptions methods. 3903f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3913f476b34049d062942eafcf48396f593e00bd324Adam Powell * @param showCustom true if the currently set custom view should be displayed, false otherwise. 3923f476b34049d062942eafcf48396f593e00bd324Adam Powell * 3933f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int) 3943f476b34049d062942eafcf48396f593e00bd324Adam Powell * @see #setDisplayOptions(int, int) 3953f476b34049d062942eafcf48396f593e00bd324Adam Powell */ 3963f476b34049d062942eafcf48396f593e00bd324Adam Powell public abstract void setDisplayShowCustomEnabled(boolean showCustom); 3973f476b34049d062942eafcf48396f593e00bd324Adam Powell 398a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell /** 39933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Set the ActionBar's background. 40033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 40133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param d Background drawable 40233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 40333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract void setBackgroundDrawable(Drawable d); 404ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell 405ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell /** 406ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @return The current custom view. 407ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell */ 408ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell public abstract View getCustomView(); 409ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell 41033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 411a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current ActionBar title in standard mode. 412a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns null if {@link #getNavigationMode()} would not return 413a408291e22def5755559f42cde913706a6d628c0Adam Powell * {@link #NAVIGATION_MODE_STANDARD}. 414a408291e22def5755559f42cde913706a6d628c0Adam Powell * 415a408291e22def5755559f42cde913706a6d628c0Adam Powell * @return The current ActionBar title or null. 41633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 41733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract CharSequence getTitle(); 41833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 41933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 420a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current ActionBar subtitle in standard mode. 421a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns null if {@link #getNavigationMode()} would not return 422a408291e22def5755559f42cde913706a6d628c0Adam Powell * {@link #NAVIGATION_MODE_STANDARD}. 423a408291e22def5755559f42cde913706a6d628c0Adam Powell * 424a408291e22def5755559f42cde913706a6d628c0Adam Powell * @return The current ActionBar subtitle or null. 42533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 42633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract CharSequence getSubtitle(); 42733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 42833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 429a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current navigation mode. The result will be one of: 430a408291e22def5755559f42cde913706a6d628c0Adam Powell * <ul> 431a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_STANDARD}</li> 4329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * <li>{@link #NAVIGATION_MODE_LIST}</li> 433a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_TABS}</li> 434a408291e22def5755559f42cde913706a6d628c0Adam Powell * </ul> 435a408291e22def5755559f42cde913706a6d628c0Adam Powell * 43633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current navigation mode. 437a408291e22def5755559f42cde913706a6d628c0Adam Powell * 438661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #setStandardNavigationMode() 439a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setStandardNavigationMode(CharSequence) 440a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setStandardNavigationMode(CharSequence, CharSequence) 441a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setDropdownNavigationMode(SpinnerAdapter) 442661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #setTabNavigationMode() 443a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setCustomNavigationMode(View) 44433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 44533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract int getNavigationMode(); 4469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 4479ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 4489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the current navigation mode. 4499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 4509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param mode The new mode to set. 4519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #NAVIGATION_MODE_STANDARD 4529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #NAVIGATION_MODE_LIST 4539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #NAVIGATION_MODE_TABS 4549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 4559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setNavigationMode(int mode); 4569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 45733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 45833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current set of display options. 45933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 46033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract int getDisplayOptions(); 461661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 462661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 463661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Create and return a new {@link Tab}. 464661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * This tab will not be included in the action bar until it is added. 465661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 4662f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn * <p>Very often tabs will be used to switch between {@link Fragment} 4672f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn * objects. Here is a typical implementation of such tabs:</p> 4682f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn * 4692f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java 4702f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn * complete} 4712f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn * 472661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return A new Tab 473661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 474661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #addTab(Tab) 475661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #insertTab(Tab, int) 476661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 477661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract Tab newTab(); 478661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 479661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 480661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. 48181b8944131946e451b31665652de8cc71d81ea07Adam Powell * If this is the first tab to be added it will become the selected tab. 482661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 483661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab Tab to add 484661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 485661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void addTab(Tab tab); 486661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 487661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 48881b8944131946e451b31665652de8cc71d81ea07Adam Powell * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. 48981b8944131946e451b31665652de8cc71d81ea07Adam Powell * 49081b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param tab Tab to add 49181b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param setSelected True if the added tab should become the selected tab. 49281b8944131946e451b31665652de8cc71d81ea07Adam Powell */ 49381b8944131946e451b31665652de8cc71d81ea07Adam Powell public abstract void addTab(Tab tab, boolean setSelected); 49481b8944131946e451b31665652de8cc71d81ea07Adam Powell 49581b8944131946e451b31665652de8cc71d81ea07Adam Powell /** 4962b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Add a tab for use in tabbed navigation mode. The tab will be inserted at 49781b8944131946e451b31665652de8cc71d81ea07Adam Powell * <code>position</code>. If this is the first tab to be added it will become 49881b8944131946e451b31665652de8cc71d81ea07Adam Powell * the selected tab. 499661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 500661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab The tab to add 501661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param position The new position of the tab 502661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 5032b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract void addTab(Tab tab, int position); 504661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 505661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 50681b8944131946e451b31665652de8cc71d81ea07Adam Powell * Add a tab for use in tabbed navigation mode. The tab will be insterted at 50781b8944131946e451b31665652de8cc71d81ea07Adam Powell * <code>position</code>. 50881b8944131946e451b31665652de8cc71d81ea07Adam Powell * 50981b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param tab The tab to add 51081b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param position The new position of the tab 51181b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param setSelected True if the added tab should become the selected tab. 51281b8944131946e451b31665652de8cc71d81ea07Adam Powell */ 51381b8944131946e451b31665652de8cc71d81ea07Adam Powell public abstract void addTab(Tab tab, int position, boolean setSelected); 51481b8944131946e451b31665652de8cc71d81ea07Adam Powell 51581b8944131946e451b31665652de8cc71d81ea07Adam Powell /** 5169ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Remove a tab from the action bar. If the removed tab was selected it will be deselected 5179ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * and another tab will be selected if present. 518661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 519661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab The tab to remove 520661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 521661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void removeTab(Tab tab); 522661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 523661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 5249ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Remove a tab from the action bar. If the removed tab was selected it will be deselected 5259ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * and another tab will be selected if present. 526661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 527661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param position Position of the tab to remove 528661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 529661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void removeTabAt(int position); 530661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 531661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 5329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Remove all tabs from the action bar and deselect the current tab. 5339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 5349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void removeAllTabs(); 5359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 5369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 537661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Select the specified tab. If it is not a child of this action bar it will be added. 538661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 5399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p> 5409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 541661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab Tab to select 542661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 543661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void selectTab(Tab tab); 544661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 545661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 5462b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Returns the currently selected tab if in tabbed navigation mode and there is at least 5472b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * one tab present. 5482b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 5492b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return The currently selected tab or null 5502b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 5512b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract Tab getSelectedTab(); 5522b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 5532b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 5549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Returns the tab at the specified index. 5559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 5569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param index Index value in the range 0-get 5579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return 5589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 5599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab getTabAt(int index); 5609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 5619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 5620c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * Returns the number of tabs currently registered with the action bar. 5630c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * @return Tab count 5640c24a5514c1ff143a223720a090b19a86a75945fAdam Powell */ 5650c24a5514c1ff143a223720a090b19a86a75945fAdam Powell public abstract int getTabCount(); 5660c24a5514c1ff143a223720a090b19a86a75945fAdam Powell 5670c24a5514c1ff143a223720a090b19a86a75945fAdam Powell /** 5686b336f835d637853800b94689375a03f337139a4Adam Powell * Retrieve the current height of the ActionBar. 5696b336f835d637853800b94689375a03f337139a4Adam Powell * 5706b336f835d637853800b94689375a03f337139a4Adam Powell * @return The ActionBar's height 5716b336f835d637853800b94689375a03f337139a4Adam Powell */ 5726b336f835d637853800b94689375a03f337139a4Adam Powell public abstract int getHeight(); 5736b336f835d637853800b94689375a03f337139a4Adam Powell 5746b336f835d637853800b94689375a03f337139a4Adam Powell /** 5756b336f835d637853800b94689375a03f337139a4Adam Powell * Show the ActionBar if it is not currently showing. 5766b336f835d637853800b94689375a03f337139a4Adam Powell * If the window hosting the ActionBar does not have the feature 5776b336f835d637853800b94689375a03f337139a4Adam Powell * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application 5786b336f835d637853800b94689375a03f337139a4Adam Powell * content to fit the new space available. 5796b336f835d637853800b94689375a03f337139a4Adam Powell */ 5806b336f835d637853800b94689375a03f337139a4Adam Powell public abstract void show(); 5816b336f835d637853800b94689375a03f337139a4Adam Powell 5826b336f835d637853800b94689375a03f337139a4Adam Powell /** 5836b336f835d637853800b94689375a03f337139a4Adam Powell * Hide the ActionBar if it is not currently showing. 5846b336f835d637853800b94689375a03f337139a4Adam Powell * If the window hosting the ActionBar does not have the feature 5856b336f835d637853800b94689375a03f337139a4Adam Powell * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application 5866b336f835d637853800b94689375a03f337139a4Adam Powell * content to fit the new space available. 5876b336f835d637853800b94689375a03f337139a4Adam Powell */ 5886b336f835d637853800b94689375a03f337139a4Adam Powell public abstract void hide(); 5896b336f835d637853800b94689375a03f337139a4Adam Powell 5906b336f835d637853800b94689375a03f337139a4Adam Powell /** 5916b336f835d637853800b94689375a03f337139a4Adam Powell * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise. 5926b336f835d637853800b94689375a03f337139a4Adam Powell */ 5936b336f835d637853800b94689375a03f337139a4Adam Powell public abstract boolean isShowing(); 5946b336f835d637853800b94689375a03f337139a4Adam Powell 5956b336f835d637853800b94689375a03f337139a4Adam Powell /** 5968515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Add a listener that will respond to menu visibility change events. 5978515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * 5988515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param listener The new listener to add 5998515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 6008515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener); 6018515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell 6028515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 6038515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Remove a menu visibility listener. This listener will no longer receive menu 6048515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * visibility change events. 6058515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * 6068515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param listener A listener to remove that was previously added 6078515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 6088515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener); 6098515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell 6108515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 611c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * Enable or disable the "home" button in the corner of the action bar. (Note that this 612c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * is the application home/up affordance on the action bar, not the systemwide home 613c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * button.) 614c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * 615c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * <p>This defaults to true for packages targeting < API 14. For packages targeting 616c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * API 14 or greater, the application should call this method to enable interaction 617c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * with the home/up affordance. 618c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * 619c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * <p>Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable 620c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * the home button. 621c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * 622c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell * @param enabled true to enable the home button, false to disable the home button. 623c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell */ 624c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell public abstract void setHomeButtonEnabled(boolean enabled); 625c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell 626c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell /** 6278515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Listener interface for ActionBar navigation events. 62889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 6298515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public interface OnNavigationListener { 63089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 63189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * This method is called whenever a navigation item in your action bar 63289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * is selected. 63389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 63489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param itemPosition Position of the item clicked. 63589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param itemId ID of the item clicked. 63689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @return True if the event was handled, false otherwise. 63789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 63889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public boolean onNavigationItemSelected(int itemPosition, long itemId); 63933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell } 640661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 641661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 6428515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Listener for receiving events when action bar menus are shown or hidden. 6438515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 6448515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public interface OnMenuVisibilityListener { 6458515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 6468515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Called when an action bar menu is shown or hidden. Applications may want to use 6478515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * this to tune auto-hiding behavior for the action bar or pause/resume video playback, 6488515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * gameplay, or other activity within the main content area. 6498515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * 6508515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param isVisible True if an action bar menu is now visible, false if no action bar 6518515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * menus are visible. 6528515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 6538515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public void onMenuVisibilityChanged(boolean isVisible); 6548515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell } 6558515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell 6568515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 657661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * A tab in the action bar. 658661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 659661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * <p>Tabs manage the hiding and showing of {@link Fragment}s. 660661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 661661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public static abstract class Tab { 662661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 663661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * An invalid position for a tab. 664661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 665661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #getPosition() 666661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 667661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public static final int INVALID_POSITION = -1; 668661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 669661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 670661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the current position of this tab in the action bar. 671661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 672661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in 673661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * the action bar. 674661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 675661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract int getPosition(); 676661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 677661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 678661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the icon associated with this tab. 679661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 680661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return The tab's icon 681661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 682661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract Drawable getIcon(); 683661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 684661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 685661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the text of this tab. 686661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 687661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return The tab's text 688661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 689661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract CharSequence getText(); 690661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 691661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 692661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the icon displayed on this tab. 693661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 694661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param icon The drawable to use as an icon 6959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 696661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 6979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setIcon(Drawable icon); 698661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 699661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 70032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * Set the icon displayed on this tab. 70132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * 70232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @param resId Resource ID referring to the drawable to use as an icon 70332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @return The current instance for call chaining 70432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell */ 70532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell public abstract Tab setIcon(int resId); 70632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell 70732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell /** 708661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the text displayed on this tab. Text may be truncated if there is not 709661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * room to display the entire string. 710661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 711661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param text The text to display 7129ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 713661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 7149ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setText(CharSequence text); 715661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 716661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 71732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * Set the text displayed on this tab. Text may be truncated if there is not 71832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * room to display the entire string. 71932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * 72032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @param resId A resource ID referring to the text that should be displayed 72132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @return The current instance for call chaining 72232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell */ 72332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell public abstract Tab setText(int resId); 72432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell 72532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell /** 7262b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Set a custom view to be used for this tab. This overrides values set by 7272b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. 728661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 7292b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param view Custom view to be used as a tab. 7309ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 731661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 7329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setCustomView(View view); 733661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 734661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 73532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * Set a custom view to be used for this tab. This overrides values set by 73632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. 73732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * 73832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @param layoutResId A layout resource to inflate and use as a custom tab view 73932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @return The current instance for call chaining 74032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell */ 74132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell public abstract Tab setCustomView(int layoutResId); 74232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell 74332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell /** 7442b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Retrieve a previously set custom view for this tab. 745661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 7462b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return The custom view set by {@link #setCustomView(View)}. 747661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 7482b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract View getCustomView(); 7492b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 7502b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7512b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Give this Tab an arbitrary object to hold for later use. 7522b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 7532b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param obj Object to store 7549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 7552b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setTag(Object obj); 7572b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 7582b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7592b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return This Tab's tag object. 7602b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7612b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract Object getTag(); 7622b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 7632b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7642b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Set the {@link TabListener} that will handle switching to and from this tab. 7652b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * All tabs must have a TabListener set before being added to the ActionBar. 7662b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 7672b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param listener Listener to handle tab selection events 7689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 7692b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setTabListener(TabListener listener); 771661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 772661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 773661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Select this tab. Only valid if the tab has been added to the action bar. 774661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 775661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void select(); 776661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell } 7772b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 7782b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7792b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Callback interface invoked when a tab is focused, unfocused, added, or removed. 7802b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7812b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public interface TabListener { 7822b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7832b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Called when a tab enters the selected state. 7842b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 7852b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param tab The tab that was selected 7862b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute 7872b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * during a tab switch. The previous tab's unselect and this tab's select will be 7880c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * executed in a single transaction. This FragmentTransaction does not support 7890c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * being added to the back stack. 7902b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7912b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public void onTabSelected(Tab tab, FragmentTransaction ft); 7922b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 7932b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7942b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Called when a tab exits the selected state. 7952b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 7962b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param tab The tab that was unselected 7972b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute 7982b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * during a tab switch. This tab's unselect and the newly selected tab's select 7990c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * will be executed in a single transaction. This FragmentTransaction does not 8000c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * support being added to the back stack. 8012b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 8022b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public void onTabUnselected(Tab tab, FragmentTransaction ft); 8037f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell 8047f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell /** 8057f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * Called when a tab that is already selected is chosen again by the user. 8067f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * Some applications may use this action to return to the top level of a category. 8077f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * 8087f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * @param tab The tab that was reselected. 8097f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute 8100c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * once this method returns. This FragmentTransaction does not support 8110c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * being added to the back stack. 8127f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell */ 8137f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell public void onTabReselected(Tab tab, FragmentTransaction ft); 8142b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell } 8159ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 8169ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 8179ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Per-child layout information associated with action bar custom views. 8189ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 8199ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity 8209ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 8219ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static class LayoutParams extends MarginLayoutParams { 8229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 8239ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Gravity for the view associated with these LayoutParams. 8249ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 8259ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see android.view.Gravity 8269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 8279ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.ExportedProperty(category = "layout", mapping = { 8289ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = -1, to = "NONE"), 8299ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"), 8309ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"), 8319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"), 8329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"), 8339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"), 8349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"), 8359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"), 8369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"), 8379ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"), 8389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"), 8399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL") 8409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell }) 8419ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public int gravity = -1; 8429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 8439ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(Context c, AttributeSet attrs) { 8449ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(c, attrs); 8459ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 8469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell TypedArray a = c.obtainStyledAttributes(attrs, 8479ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell com.android.internal.R.styleable.ActionBar_LayoutParams); 8489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell gravity = a.getInt( 8499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell com.android.internal.R.styleable.ActionBar_LayoutParams_layout_gravity, -1); 8509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 8519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 8529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(int width, int height) { 8539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(width, height); 8549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; 8559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 8569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 8579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(int width, int height, int gravity) { 8589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(width, height); 8599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this.gravity = gravity; 8609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 8619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 8629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(int gravity) { 8639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this(WRAP_CONTENT, MATCH_PARENT, gravity); 8649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 8659ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 8669ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(LayoutParams source) { 8679ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(source); 8689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 8699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this.gravity = source.gravity; 8709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 8719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 8729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(ViewGroup.LayoutParams source) { 8739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(source); 8749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 8759ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 87633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell} 877