ActionBar.java revision cf0357639e952a87f0d535c82691919af81f058b
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; 529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated use NAVIGATION_MODE_LIST 559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 5733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int NAVIGATION_MODE_DROPDOWN_LIST = 1; 5833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 5933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 6033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Tab navigation mode. Instead of static title text this mode 6133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * presents a series of tabs for navigation within the activity. 6233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 6333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int NAVIGATION_MODE_TABS = 2; 6433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 6533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 6633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Use logo instead of icon if available. This flag will cause appropriate 6733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * navigation modes to use a wider logo in place of the standard icon. 689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 7133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 7233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int DISPLAY_USE_LOGO = 0x1; 7333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 7433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 759ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Show 'home' elements in this action bar, leaving more space for other 7633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * navigation elements. This includes logo and icon. 779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_SHOW_HOME = 0x2; 829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 849ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated Display flags are now positive for consistency - 'show' instead of 'hide'. 859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Use DISPLAY_SHOW_HOME. 869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_HIDE_HOME = 0x1000; 899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 909ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 919ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Display the 'home' element such that it appears as an 'up' affordance. 929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * e.g. show an arrow to the left indicating the action that will be taken. 939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 949ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set this flag if selecting the 'home' button in the action bar to return 959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * up by a single level in your UI rather than back to the top level or front page. 969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 989ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 999ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1009ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_HOME_AS_UP = 0x4; 1019ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1029ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1039ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Show the activity title and subtitle, if present. 1049ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1059ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setTitle(CharSequence) 1069ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setTitle(int) 1079ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setSubtitle(CharSequence) 1089ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setSubtitle(int) 1099ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 1109ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 1119ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1129ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_SHOW_TITLE = 0x8; 1139ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1149ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1159ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Show the custom view if one has been set. 1169ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setCustomView(View) 1179ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 1189ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 1199ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1209ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_SHOW_CUSTOM = 0x10; 1219ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1239ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the action bar into custom navigation mode, supplying a view 1249ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * for custom navigation. 1259ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Custom navigation views appear between the application icon and 1279ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * any action buttons and may use any space available there. Common 1289ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * use cases for custom navigation views might include an auto-suggesting 1299ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * address bar for a browser or other navigation mechanisms that do not 1309ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * translate well to provided navigation modes. 1319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param view Custom navigation view to place in the ActionBar. 13333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setCustomView(View view); 13589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 13633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 137a408291e22def5755559f42cde913706a6d628c0Adam Powell * Set the action bar into custom navigation mode, supplying a view 138a408291e22def5755559f42cde913706a6d628c0Adam Powell * for custom navigation. 13933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 140ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * <p>Custom navigation views appear between the application icon and 14133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * any action buttons and may use any space available there. Common 142a408291e22def5755559f42cde913706a6d628c0Adam Powell * use cases for custom navigation views might include an auto-suggesting 143a408291e22def5755559f42cde913706a6d628c0Adam Powell * address bar for a browser or other navigation mechanisms that do not 144ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * translate well to provided navigation modes.</p> 145ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * 146ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for 147ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * the custom view to be displayed.</p> 14833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 14933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param view Custom navigation view to place in the ActionBar. 1509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param layoutParams How this custom view should layout in the bar. 151ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * 152ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 15333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setCustomView(View view, LayoutParams layoutParams); 1559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param view 1589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated Use {@link #setCustomView(View)} and {@link #setDisplayOptions(int)} instead. 1599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 161a408291e22def5755559f42cde913706a6d628c0Adam Powell public abstract void setCustomNavigationMode(View view); 16233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 16333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 164a408291e22def5755559f42cde913706a6d628c0Adam Powell * Set the action bar into dropdown navigation mode and supply an adapter 165a408291e22def5755559f42cde913706a6d628c0Adam Powell * that will provide views for navigation choices. 16633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 167a408291e22def5755559f42cde913706a6d628c0Adam Powell * @param adapter An adapter that will provide views both to display 168a408291e22def5755559f42cde913706a6d628c0Adam Powell * the current navigation selection and populate views 169a408291e22def5755559f42cde913706a6d628c0Adam Powell * within the dropdown navigation menu. 1708515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param callback A OnNavigationListener that will receive events when the user 17189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * selects a navigation item. 1729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated See setListNavigationCallbacks. 17333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 17589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void setDropdownNavigationMode(SpinnerAdapter adapter, 1768515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell OnNavigationListener callback); 177a408291e22def5755559f42cde913706a6d628c0Adam Powell 17833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 1799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the adapter and navigation callback for list navigation mode. 1809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * The supplied adapter will provide views for the expanded list as well as 1829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * the currently selected item. (These may be displayed differently.) 1839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1848515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * The supplied OnNavigationListener will alert the application when the user 1859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * changes the current list selection. 1869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param adapter An adapter that will provide views both to display 1889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * the current navigation selection and populate views 1899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * within the dropdown navigation menu. 1908515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param callback An OnNavigationListener that will receive events when the user 1919ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * selects a navigation item. 1929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, 1948515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell OnNavigationListener callback); 1959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 197178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * Set the action bar into dropdown navigation mode and supply an adapter that will 198178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * provide views for navigation choices. 199178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * 200178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @param adapter An adapter that will provide views both to display the current 201178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * navigation selection and populate views within the dropdown 202178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * navigation menu. 2038515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param callback A OnNavigationListener that will receive events when the user 204178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * selects a navigation item. 205178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @param defaultSelectedPosition Position within the provided adapter that should be 206178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * selected from the outset. 2079ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated See setListNavigationCallbacks and setSelectedNavigationItem. 208178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell */ 2099ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 210178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell public abstract void setDropdownNavigationMode(SpinnerAdapter adapter, 2118515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell OnNavigationListener callback, int defaultSelectedPosition); 212178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell 213178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell /** 2149ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the selected navigation item in list or tabbed navigation modes. 215178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * 216178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @param position Position of the item to select. 217178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell */ 218178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell public abstract void setSelectedNavigationItem(int position); 219178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell 220178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell /** 2219ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Get the position of the selected navigation item in list or tabbed navigation modes. 222178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * 223178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @return Position of the selected item. 2249ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated Use {@link #getSelectedNavigationIndex()} instead. 225178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell */ 2269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 227178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell public abstract int getSelectedNavigationItem(); 228178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell 229178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell /** 2309ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Get the position of the selected navigation item in list or tabbed navigation modes. 2319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 2329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return Position of the selected item. 2339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 2349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract int getSelectedNavigationIndex(); 2359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 2369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 2379ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Get the number of navigation items present in the current navigation mode. 2389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 2399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return Number of navigation items. 2409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 2419ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract int getNavigationItemCount(); 2429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 2439ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 2440e94b5151d817e600a888448a662208b29b5ef46Adam Powell * Set the action bar into standard navigation mode, using the currently set title 2450e94b5151d817e600a888448a662208b29b5ef46Adam Powell * and/or subtitle. 2460e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 2470e94b5151d817e600a888448a662208b29b5ef46Adam Powell * Standard navigation mode is default. The title is automatically set to the name of 2480e94b5151d817e600a888448a662208b29b5ef46Adam Powell * your Activity on startup if an action bar is present. 2499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated See setNavigationMode 2500e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 2519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 2520e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setStandardNavigationMode(); 2530e94b5151d817e600a888448a662208b29b5ef46Adam Powell 2540e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 255ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's title. This will only be displayed if 256ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. 2570e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 2580e94b5151d817e600a888448a662208b29b5ef46Adam Powell * @param title Title to set 259a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 260a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setTitle(int) 261ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 2620e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 2630e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setTitle(CharSequence title); 2640e94b5151d817e600a888448a662208b29b5ef46Adam Powell 2650e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 266ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's title. This will only be displayed if 267ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. 268a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 269a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @param resId Resource ID of title string to set 270a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 271a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setTitle(CharSequence) 272ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 273a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell */ 274a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell public abstract void setTitle(int resId); 275a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell 276a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell /** 277ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's subtitle. This will only be displayed if 278ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the 279ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * subtitle entirely. 2800e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 2810e94b5151d817e600a888448a662208b29b5ef46Adam Powell * @param subtitle Subtitle to set 282a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 283a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setSubtitle(int) 284ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 2850e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 2860e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setSubtitle(CharSequence subtitle); 2870e94b5151d817e600a888448a662208b29b5ef46Adam Powell 2880e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 289ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's subtitle. This will only be displayed if 290ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. 291a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 292a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @param resId Resource ID of subtitle string to set 293a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 294a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setSubtitle(CharSequence) 295ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 296a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell */ 297a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell public abstract void setSubtitle(int resId); 298a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell 299a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell /** 300a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * Set display options. This changes all display option bits at once. To change 301a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * a limited subset of display options, see {@link #setDisplayOptions(int, int)}. 30233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 30333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param options A combination of the bits defined by the DISPLAY_ constants 30433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * defined in ActionBar. 30533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 30633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract void setDisplayOptions(int options); 30733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 30833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 309a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * Set selected display options. Only the options specified by mask will be changed. 310a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * To change all display option bits at once, see {@link #setDisplayOptions(int)}. 311a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * 3129ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the 3139ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * {@link #DISPLAY_SHOW_HOME} option. 3145ad7af6fc764f71765b134b8cd51787a7e78753aBen Komalo * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) 3159ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}. 316a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * 317a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * @param options A combination of the bits defined by the DISPLAY_ constants 318a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * defined in ActionBar. 319a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * @param mask A bit mask declaring which display options should be changed. 320a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell */ 321a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell public abstract void setDisplayOptions(int options, int mask); 322a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell 323a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell /** 32433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Set the ActionBar's background. 32533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 32633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param d Background drawable 32733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 32833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract void setBackgroundDrawable(Drawable d); 32933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 33033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 33133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current custom navigation view. 332ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @deprecated Method has been renamed. Use {@link #getCustomView()}. 33333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 334ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell @Deprecated 33533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract View getCustomNavigationView(); 336ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell 337ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell /** 338ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @return The current custom view. 339ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell */ 340ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell public abstract View getCustomView(); 341ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell 34233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 343a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current ActionBar title in standard mode. 344a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns null if {@link #getNavigationMode()} would not return 345a408291e22def5755559f42cde913706a6d628c0Adam Powell * {@link #NAVIGATION_MODE_STANDARD}. 346a408291e22def5755559f42cde913706a6d628c0Adam Powell * 347a408291e22def5755559f42cde913706a6d628c0Adam Powell * @return The current ActionBar title or null. 34833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 34933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract CharSequence getTitle(); 35033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 35133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 352a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current ActionBar subtitle in standard mode. 353a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns null if {@link #getNavigationMode()} would not return 354a408291e22def5755559f42cde913706a6d628c0Adam Powell * {@link #NAVIGATION_MODE_STANDARD}. 355a408291e22def5755559f42cde913706a6d628c0Adam Powell * 356a408291e22def5755559f42cde913706a6d628c0Adam Powell * @return The current ActionBar subtitle or null. 35733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 35833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract CharSequence getSubtitle(); 35933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 36033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 361a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current navigation mode. The result will be one of: 362a408291e22def5755559f42cde913706a6d628c0Adam Powell * <ul> 363a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_STANDARD}</li> 3649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * <li>{@link #NAVIGATION_MODE_LIST}</li> 365a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_TABS}</li> 366a408291e22def5755559f42cde913706a6d628c0Adam Powell * </ul> 367a408291e22def5755559f42cde913706a6d628c0Adam Powell * 36833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current navigation mode. 369a408291e22def5755559f42cde913706a6d628c0Adam Powell * 370661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #setStandardNavigationMode() 371a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setStandardNavigationMode(CharSequence) 372a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setStandardNavigationMode(CharSequence, CharSequence) 373a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setDropdownNavigationMode(SpinnerAdapter) 374661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #setTabNavigationMode() 375a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setCustomNavigationMode(View) 37633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 37733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract int getNavigationMode(); 3789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 3799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 3809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the current navigation mode. 3819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 3829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param mode The new mode to set. 3839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #NAVIGATION_MODE_STANDARD 3849ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #NAVIGATION_MODE_LIST 3859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #NAVIGATION_MODE_TABS 3869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 3879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setNavigationMode(int mode); 3889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 38933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 39033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current set of display options. 39133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 39233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract int getDisplayOptions(); 393661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 394661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 395661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the action bar into tabbed navigation mode. 396661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 397661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #addTab(Tab) 398661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #insertTab(Tab, int) 399661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #removeTab(Tab) 400661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #removeTabAt(int) 4019ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 4029ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated See {@link #setNavigationMode(int)} 403661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 404661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void setTabNavigationMode(); 405661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 406661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 407661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Create and return a new {@link Tab}. 408661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * This tab will not be included in the action bar until it is added. 409661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 410661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return A new Tab 411661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 412661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #addTab(Tab) 413661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #insertTab(Tab, int) 414661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 415661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract Tab newTab(); 416661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 417661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 418661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. 41981b8944131946e451b31665652de8cc71d81ea07Adam Powell * If this is the first tab to be added it will become the selected tab. 420661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 421661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab Tab to add 422661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 423661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void addTab(Tab tab); 424661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 425661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 42681b8944131946e451b31665652de8cc71d81ea07Adam Powell * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. 42781b8944131946e451b31665652de8cc71d81ea07Adam Powell * 42881b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param tab Tab to add 42981b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param setSelected True if the added tab should become the selected tab. 43081b8944131946e451b31665652de8cc71d81ea07Adam Powell */ 43181b8944131946e451b31665652de8cc71d81ea07Adam Powell public abstract void addTab(Tab tab, boolean setSelected); 43281b8944131946e451b31665652de8cc71d81ea07Adam Powell 43381b8944131946e451b31665652de8cc71d81ea07Adam Powell /** 4342b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Add a tab for use in tabbed navigation mode. The tab will be inserted at 43581b8944131946e451b31665652de8cc71d81ea07Adam Powell * <code>position</code>. If this is the first tab to be added it will become 43681b8944131946e451b31665652de8cc71d81ea07Adam Powell * the selected tab. 437661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 438661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab The tab to add 439661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param position The new position of the tab 440661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 4412b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract void addTab(Tab tab, int position); 442661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 443661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 44481b8944131946e451b31665652de8cc71d81ea07Adam Powell * Add a tab for use in tabbed navigation mode. The tab will be insterted at 44581b8944131946e451b31665652de8cc71d81ea07Adam Powell * <code>position</code>. 44681b8944131946e451b31665652de8cc71d81ea07Adam Powell * 44781b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param tab The tab to add 44881b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param position The new position of the tab 44981b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param setSelected True if the added tab should become the selected tab. 45081b8944131946e451b31665652de8cc71d81ea07Adam Powell */ 45181b8944131946e451b31665652de8cc71d81ea07Adam Powell public abstract void addTab(Tab tab, int position, boolean setSelected); 45281b8944131946e451b31665652de8cc71d81ea07Adam Powell 45381b8944131946e451b31665652de8cc71d81ea07Adam Powell /** 4549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Remove a tab from the action bar. If the removed tab was selected it will be deselected 4559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * and another tab will be selected if present. 456661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 457661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab The tab to remove 458661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 459661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void removeTab(Tab tab); 460661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 461661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 4629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Remove a tab from the action bar. If the removed tab was selected it will be deselected 4639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * and another tab will be selected if present. 464661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 465661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param position Position of the tab to remove 466661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 467661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void removeTabAt(int position); 468661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 469661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 4709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Remove all tabs from the action bar and deselect the current tab. 4719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 4729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void removeAllTabs(); 4739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 4749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 475661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Select the specified tab. If it is not a child of this action bar it will be added. 476661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 4779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p> 4789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 479661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab Tab to select 480661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 481661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void selectTab(Tab tab); 482661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 483661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 4842b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Returns the currently selected tab if in tabbed navigation mode and there is at least 4852b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * one tab present. 4862b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 4872b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return The currently selected tab or null 4882b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 4892b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract Tab getSelectedTab(); 4902b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 4912b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 4929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Returns the tab at the specified index. 4939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 4949ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param index Index value in the range 0-get 4959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return 4969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 4979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab getTabAt(int index); 4989ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 4999ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 5000c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * Returns the number of tabs currently registered with the action bar. 5010c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * @return Tab count 5020c24a5514c1ff143a223720a090b19a86a75945fAdam Powell */ 5030c24a5514c1ff143a223720a090b19a86a75945fAdam Powell public abstract int getTabCount(); 5040c24a5514c1ff143a223720a090b19a86a75945fAdam Powell 5050c24a5514c1ff143a223720a090b19a86a75945fAdam Powell /** 5066b336f835d637853800b94689375a03f337139a4Adam Powell * Retrieve the current height of the ActionBar. 5076b336f835d637853800b94689375a03f337139a4Adam Powell * 5086b336f835d637853800b94689375a03f337139a4Adam Powell * @return The ActionBar's height 5096b336f835d637853800b94689375a03f337139a4Adam Powell */ 5106b336f835d637853800b94689375a03f337139a4Adam Powell public abstract int getHeight(); 5116b336f835d637853800b94689375a03f337139a4Adam Powell 5126b336f835d637853800b94689375a03f337139a4Adam Powell /** 5136b336f835d637853800b94689375a03f337139a4Adam Powell * Show the ActionBar if it is not currently showing. 5146b336f835d637853800b94689375a03f337139a4Adam Powell * If the window hosting the ActionBar does not have the feature 5156b336f835d637853800b94689375a03f337139a4Adam Powell * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application 5166b336f835d637853800b94689375a03f337139a4Adam Powell * content to fit the new space available. 5176b336f835d637853800b94689375a03f337139a4Adam Powell */ 5186b336f835d637853800b94689375a03f337139a4Adam Powell public abstract void show(); 5196b336f835d637853800b94689375a03f337139a4Adam Powell 5206b336f835d637853800b94689375a03f337139a4Adam Powell /** 5216b336f835d637853800b94689375a03f337139a4Adam Powell * Hide the ActionBar if it is not currently showing. 5226b336f835d637853800b94689375a03f337139a4Adam Powell * If the window hosting the ActionBar does not have the feature 5236b336f835d637853800b94689375a03f337139a4Adam Powell * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application 5246b336f835d637853800b94689375a03f337139a4Adam Powell * content to fit the new space available. 5256b336f835d637853800b94689375a03f337139a4Adam Powell */ 5266b336f835d637853800b94689375a03f337139a4Adam Powell public abstract void hide(); 5276b336f835d637853800b94689375a03f337139a4Adam Powell 5286b336f835d637853800b94689375a03f337139a4Adam Powell /** 5296b336f835d637853800b94689375a03f337139a4Adam Powell * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise. 5306b336f835d637853800b94689375a03f337139a4Adam Powell */ 5316b336f835d637853800b94689375a03f337139a4Adam Powell public abstract boolean isShowing(); 5326b336f835d637853800b94689375a03f337139a4Adam Powell 5336b336f835d637853800b94689375a03f337139a4Adam Powell /** 5348515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Add a listener that will respond to menu visibility change events. 5358515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * 5368515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param listener The new listener to add 5378515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 5388515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener); 5398515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell 5408515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 5418515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Remove a menu visibility listener. This listener will no longer receive menu 5428515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * visibility change events. 5438515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * 5448515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param listener A listener to remove that was previously added 5458515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 5468515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener); 5478515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell 5488515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 5498515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Listener interface for ActionBar navigation events. 55089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 5518515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public interface OnNavigationListener { 55289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 55389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * This method is called whenever a navigation item in your action bar 55489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * is selected. 55589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 55689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param itemPosition Position of the item clicked. 55789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param itemId ID of the item clicked. 55889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @return True if the event was handled, false otherwise. 55989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 56089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public boolean onNavigationItemSelected(int itemPosition, long itemId); 56133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell } 562661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 563661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 5648515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Listener for receiving events when action bar menus are shown or hidden. 5658515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 5668515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public interface OnMenuVisibilityListener { 5678515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 5688515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Called when an action bar menu is shown or hidden. Applications may want to use 5698515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * this to tune auto-hiding behavior for the action bar or pause/resume video playback, 5708515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * gameplay, or other activity within the main content area. 5718515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * 5728515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param isVisible True if an action bar menu is now visible, false if no action bar 5738515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * menus are visible. 5748515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 5758515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public void onMenuVisibilityChanged(boolean isVisible); 5768515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell } 5778515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell 5788515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 579661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * A tab in the action bar. 580661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 581661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * <p>Tabs manage the hiding and showing of {@link Fragment}s. 582661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 583661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public static abstract class Tab { 584661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 585661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * An invalid position for a tab. 586661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 587661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #getPosition() 588661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 589661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public static final int INVALID_POSITION = -1; 590661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 591661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 592661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the current position of this tab in the action bar. 593661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 594661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in 595661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * the action bar. 596661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 597661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract int getPosition(); 598661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 599661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 600661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the icon associated with this tab. 601661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 602661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return The tab's icon 603661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 604661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract Drawable getIcon(); 605661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 606661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 607661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the text of this tab. 608661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 609661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return The tab's text 610661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 611661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract CharSequence getText(); 612661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 613661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 614661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the icon displayed on this tab. 615661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 616661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param icon The drawable to use as an icon 6179ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 618661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 6199ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setIcon(Drawable icon); 620661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 621661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 62232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * Set the icon displayed on this tab. 62332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * 62432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @param resId Resource ID referring to the drawable to use as an icon 62532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @return The current instance for call chaining 62632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell */ 62732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell public abstract Tab setIcon(int resId); 62832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell 62932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell /** 630661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the text displayed on this tab. Text may be truncated if there is not 631661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * room to display the entire string. 632661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 633661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param text The text to display 6349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 635661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 6369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setText(CharSequence text); 637661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 638661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 63932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * Set the text displayed on this tab. Text may be truncated if there is not 64032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * room to display the entire string. 64132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * 64232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @param resId A resource ID referring to the text that should be displayed 64332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @return The current instance for call chaining 64432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell */ 64532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell public abstract Tab setText(int resId); 64632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell 64732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell /** 6482b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Set a custom view to be used for this tab. This overrides values set by 6492b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. 650661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 6512b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param view Custom view to be used as a tab. 6529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 653661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 6549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setCustomView(View view); 655661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 656661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 65732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * Set a custom view to be used for this tab. This overrides values set by 65832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. 65932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * 66032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @param layoutResId A layout resource to inflate and use as a custom tab view 66132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @return The current instance for call chaining 66232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell */ 66332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell public abstract Tab setCustomView(int layoutResId); 66432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell 66532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell /** 6662b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Retrieve a previously set custom view for this tab. 667661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 6682b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return The custom view set by {@link #setCustomView(View)}. 669661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 6702b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract View getCustomView(); 6712b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 6722b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 6732b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Give this Tab an arbitrary object to hold for later use. 6742b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 6752b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param obj Object to store 6769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 6772b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 6789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setTag(Object obj); 6792b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 6802b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 6812b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return This Tab's tag object. 6822b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 6832b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract Object getTag(); 6842b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 6852b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 6862b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Set the {@link TabListener} that will handle switching to and from this tab. 6872b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * All tabs must have a TabListener set before being added to the ActionBar. 6882b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 6892b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param listener Listener to handle tab selection events 6909ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 6912b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 6929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setTabListener(TabListener listener); 693661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 694661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 695661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Select this tab. Only valid if the tab has been added to the action bar. 696661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 697661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void select(); 698661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell } 6992b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 7002b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7012b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Callback interface invoked when a tab is focused, unfocused, added, or removed. 7022b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7032b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public interface TabListener { 7042b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7052b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Called when a tab enters the selected state. 7062b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 7072b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param tab The tab that was selected 7082b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute 7092b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * during a tab switch. The previous tab's unselect and this tab's select will be 7100c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * executed in a single transaction. This FragmentTransaction does not support 7110c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * being added to the back stack. 7122b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7132b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public void onTabSelected(Tab tab, FragmentTransaction ft); 7142b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 7152b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7162b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Called when a tab exits the selected state. 7172b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 7182b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param tab The tab that was unselected 7192b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute 7202b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * during a tab switch. This tab's unselect and the newly selected tab's select 7210c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * will be executed in a single transaction. This FragmentTransaction does not 7220c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * support being added to the back stack. 7232b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7242b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public void onTabUnselected(Tab tab, FragmentTransaction ft); 7257f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell 7267f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell /** 7277f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * Called when a tab that is already selected is chosen again by the user. 7287f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * Some applications may use this action to return to the top level of a category. 7297f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * 7307f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * @param tab The tab that was reselected. 7317f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute 7320c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * once this method returns. This FragmentTransaction does not support 7330c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * being added to the back stack. 7347f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell */ 7357f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell public void onTabReselected(Tab tab, FragmentTransaction ft); 7362b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell } 7379ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 7399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Per-child layout information associated with action bar custom views. 7409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 7419ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity 7429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 7439ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static class LayoutParams extends MarginLayoutParams { 7449ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 7459ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Gravity for the view associated with these LayoutParams. 7469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 7479ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see android.view.Gravity 7489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 7499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.ExportedProperty(category = "layout", mapping = { 7509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = -1, to = "NONE"), 7519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"), 7529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"), 7539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"), 7549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"), 7559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"), 7569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"), 7579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"), 7589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"), 7599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"), 7609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"), 7619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL") 7629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell }) 7639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public int gravity = -1; 7649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7659ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(Context c, AttributeSet attrs) { 7669ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(c, attrs); 7679ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell TypedArray a = c.obtainStyledAttributes(attrs, 7699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell com.android.internal.R.styleable.ActionBar_LayoutParams); 7709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell gravity = a.getInt( 7719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell com.android.internal.R.styleable.ActionBar_LayoutParams_layout_gravity, -1); 7729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(int width, int height) { 7759ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(width, height); 7769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; 7779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(int width, int height, int gravity) { 7809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(width, height); 7819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this.gravity = gravity; 7829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7849ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(int gravity) { 7859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this(WRAP_CONTENT, MATCH_PARENT, gravity); 7869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(LayoutParams source) { 7899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(source); 7909ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7919ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this.gravity = source.gravity; 7929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7949ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(ViewGroup.LayoutParams source) { 7959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(source); 7969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 79833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell} 799