ActionBar.java revision 8515ee846bd76aee86ec5ddfcc4dd1e626dd999c
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.app.ActionBar.Tab; 209ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.content.Context; 219ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.content.res.TypedArray; 2233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellimport android.graphics.drawable.Drawable; 239ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.util.AttributeSet; 249ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.view.Gravity; 2533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellimport android.view.View; 269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.view.ViewDebug; 279ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.view.ViewGroup; 289ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powellimport android.view.ViewGroup.MarginLayoutParams; 296b336f835d637853800b94689375a03f337139a4Adam Powellimport android.view.Window; 30a408291e22def5755559f42cde913706a6d628c0Adam Powellimport android.widget.SpinnerAdapter; 3133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 3233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell/** 3333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * This is the public interface to the contextual ActionBar. 3433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * The ActionBar acts as a replacement for the title bar in Activities. 3533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * It provides facilities for creating toolbar actions as well as 3633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * methods of navigating around an application. 3733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 3833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellpublic abstract class ActionBar { 39a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell /** 40a408291e22def5755559f42cde913706a6d628c0Adam Powell * Standard navigation mode. Consists of either a logo or icon 41a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * and title text with an optional subtitle. Clicking any of these elements 42a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * will dispatch onActionItemSelected to the registered Callback with 43a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * a MenuItem with item ID android.R.id.home. 44a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell */ 45a408291e22def5755559f42cde913706a6d628c0Adam Powell public static final int NAVIGATION_MODE_STANDARD = 0; 4633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 4733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * List navigation mode. Instead of static title text this mode 499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * presents a list menu for navigation within the activity. 509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * e.g. this might be presented to the user as a dropdown list. 5133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int NAVIGATION_MODE_LIST = 1; 539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated use NAVIGATION_MODE_LIST 569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 5833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int NAVIGATION_MODE_DROPDOWN_LIST = 1; 5933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 6033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 6133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Tab navigation mode. Instead of static title text this mode 6233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * presents a series of tabs for navigation within the activity. 6333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 6433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int NAVIGATION_MODE_TABS = 2; 6533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 6633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 6733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Use logo instead of icon if available. This flag will cause appropriate 6833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * navigation modes to use a wider logo in place of the standard icon. 699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 7233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 7333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int DISPLAY_USE_LOGO = 0x1; 7433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 7533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Show 'home' elements in this action bar, leaving more space for other 7733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * navigation elements. This includes logo and icon. 789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_SHOW_HOME = 0x2; 839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 849ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated Display flags are now positive for consistency - 'show' instead of 'hide'. 869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Use DISPLAY_SHOW_HOME. 879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_HIDE_HOME = 0x1000; 909ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 919ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Display the 'home' element such that it appears as an 'up' affordance. 939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * e.g. show an arrow to the left indicating the action that will be taken. 949ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set this flag if selecting the 'home' button in the action bar to return 969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * up by a single level in your UI rather than back to the top level or front page. 979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 989ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 999ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 1009ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1019ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_HOME_AS_UP = 0x4; 1029ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1039ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1049ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Show the activity title and subtitle, if present. 1059ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1069ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setTitle(CharSequence) 1079ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setTitle(int) 1089ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setSubtitle(CharSequence) 1099ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setSubtitle(int) 1109ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 1119ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 1129ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1139ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_SHOW_TITLE = 0x8; 1149ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1159ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1169ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Show the custom view if one has been set. 1179ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setCustomView(View) 1189ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int) 1199ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #setDisplayOptions(int, int) 1209ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1219ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static final int DISPLAY_SHOW_CUSTOM = 0x10; 1229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1239ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1249ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the action bar into custom navigation mode, supplying a view 1259ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * for custom navigation. 1269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1279ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Custom navigation views appear between the application icon and 1289ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * any action buttons and may use any space available there. Common 1299ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * use cases for custom navigation views might include an auto-suggesting 1309ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * address bar for a browser or other navigation mechanisms that do not 1319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * translate well to provided navigation modes. 1329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param view Custom navigation view to place in the ActionBar. 13433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setCustomView(View view); 13689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 13733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 138a408291e22def5755559f42cde913706a6d628c0Adam Powell * Set the action bar into custom navigation mode, supplying a view 139a408291e22def5755559f42cde913706a6d628c0Adam Powell * for custom navigation. 14033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 141ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * <p>Custom navigation views appear between the application icon and 14233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * any action buttons and may use any space available there. Common 143a408291e22def5755559f42cde913706a6d628c0Adam Powell * use cases for custom navigation views might include an auto-suggesting 144a408291e22def5755559f42cde913706a6d628c0Adam Powell * address bar for a browser or other navigation mechanisms that do not 145ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * translate well to provided navigation modes.</p> 146ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * 147ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for 148ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * the custom view to be displayed.</p> 14933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 15033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param view Custom navigation view to place in the ActionBar. 1519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param layoutParams How this custom view should layout in the bar. 152ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * 153ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 15433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setCustomView(View view, LayoutParams layoutParams); 1569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 1589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param view 1599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated Use {@link #setCustomView(View)} and {@link #setDisplayOptions(int)} instead. 1609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 162a408291e22def5755559f42cde913706a6d628c0Adam Powell public abstract void setCustomNavigationMode(View view); 16333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 16433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 165a408291e22def5755559f42cde913706a6d628c0Adam Powell * Set the action bar into dropdown navigation mode and supply an adapter 166a408291e22def5755559f42cde913706a6d628c0Adam Powell * that will provide views for navigation choices. 16733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 168a408291e22def5755559f42cde913706a6d628c0Adam Powell * @param adapter An adapter that will provide views both to display 169a408291e22def5755559f42cde913706a6d628c0Adam Powell * the current navigation selection and populate views 170a408291e22def5755559f42cde913706a6d628c0Adam Powell * within the dropdown navigation menu. 1718515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param callback A OnNavigationListener that will receive events when the user 17289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * selects a navigation item. 1739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated See setListNavigationCallbacks. 17433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1759ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 17689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void setDropdownNavigationMode(SpinnerAdapter adapter, 1778515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell OnNavigationListener callback); 178a408291e22def5755559f42cde913706a6d628c0Adam Powell 17933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 1809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the adapter and navigation callback for list navigation mode. 1819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * The supplied adapter will provide views for the expanded list as well as 1839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * the currently selected item. (These may be displayed differently.) 1849ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1858515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * The supplied OnNavigationListener will alert the application when the user 1869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * changes the current list selection. 1879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 1889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param adapter An adapter that will provide views both to display 1899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * the current navigation selection and populate views 1909ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * within the dropdown navigation menu. 1918515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param callback An OnNavigationListener that will receive events when the user 1929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * selects a navigation item. 1939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 1949ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, 1958515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell OnNavigationListener callback); 1969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 1979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 198178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * Set the action bar into dropdown navigation mode and supply an adapter that will 199178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * provide views for navigation choices. 200178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * 201178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @param adapter An adapter that will provide views both to display the current 202178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * navigation selection and populate views within the dropdown 203178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * navigation menu. 2048515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param callback A OnNavigationListener that will receive events when the user 205178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * selects a navigation item. 206178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @param defaultSelectedPosition Position within the provided adapter that should be 207178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * selected from the outset. 2089ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated See setListNavigationCallbacks and setSelectedNavigationItem. 209178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell */ 2109ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 211178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell public abstract void setDropdownNavigationMode(SpinnerAdapter adapter, 2128515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell OnNavigationListener callback, int defaultSelectedPosition); 213178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell 214178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell /** 2159ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the selected navigation item in list or tabbed navigation modes. 216178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * 217178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @param position Position of the item to select. 218178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell */ 219178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell public abstract void setSelectedNavigationItem(int position); 220178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell 221178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell /** 2229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Get the position of the selected navigation item in list or tabbed navigation modes. 223178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * 224178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell * @return Position of the selected item. 2259ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated Use {@link #getSelectedNavigationIndex()} instead. 226178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell */ 2279ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 228178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell public abstract int getSelectedNavigationItem(); 229178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell 230178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell /** 2319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Get the position of the selected navigation item in list or tabbed navigation modes. 2329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 2339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return Position of the selected item. 2349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 2359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract int getSelectedNavigationIndex(); 2369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 2379ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 2389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Get the number of navigation items present in the current navigation mode. 2399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 2409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return Number of navigation items. 2419ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 2429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract int getNavigationItemCount(); 2439ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 2449ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 2450e94b5151d817e600a888448a662208b29b5ef46Adam Powell * Set the action bar into standard navigation mode, using the currently set title 2460e94b5151d817e600a888448a662208b29b5ef46Adam Powell * and/or subtitle. 2470e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 2480e94b5151d817e600a888448a662208b29b5ef46Adam Powell * Standard navigation mode is default. The title is automatically set to the name of 2490e94b5151d817e600a888448a662208b29b5ef46Adam Powell * your Activity on startup if an action bar is present. 2509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated See setNavigationMode 2510e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 2529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @Deprecated 2530e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setStandardNavigationMode(); 2540e94b5151d817e600a888448a662208b29b5ef46Adam Powell 2550e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 256ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's title. This will only be displayed if 257ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. 2580e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 2590e94b5151d817e600a888448a662208b29b5ef46Adam Powell * @param title Title to set 260a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 261a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setTitle(int) 262ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 2630e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 2640e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setTitle(CharSequence title); 2650e94b5151d817e600a888448a662208b29b5ef46Adam Powell 2660e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 267ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's title. This will only be displayed if 268ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. 269a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 270a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @param resId Resource ID of title string to set 271a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 272a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setTitle(CharSequence) 273ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 274a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell */ 275a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell public abstract void setTitle(int resId); 276a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell 277a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell /** 278ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's subtitle. This will only be displayed if 279ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the 280ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * subtitle entirely. 2810e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 2820e94b5151d817e600a888448a662208b29b5ef46Adam Powell * @param subtitle Subtitle to set 283a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 284a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setSubtitle(int) 285ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 2860e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 2870e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setSubtitle(CharSequence subtitle); 2880e94b5151d817e600a888448a662208b29b5ef46Adam Powell 2890e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 290ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * Set the action bar's subtitle. This will only be displayed if 291ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * {@link #DISPLAY_SHOW_TITLE} is set. 292a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 293a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @param resId Resource ID of subtitle string to set 294a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * 295a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell * @see #setSubtitle(CharSequence) 296ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @see #setDisplayOptions(int, int) 297a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell */ 298a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell public abstract void setSubtitle(int resId); 299a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell 300a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell /** 301a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * Set display options. This changes all display option bits at once. To change 302a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * a limited subset of display options, see {@link #setDisplayOptions(int, int)}. 30333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 30433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param options A combination of the bits defined by the DISPLAY_ constants 30533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * defined in ActionBar. 30633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 30733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract void setDisplayOptions(int options); 30833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 30933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 310a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * Set selected display options. Only the options specified by mask will be changed. 311a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * To change all display option bits at once, see {@link #setDisplayOptions(int)}. 312a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * 3139ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the 3149ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * {@link #DISPLAY_SHOW_HOME} option. 3155ad7af6fc764f71765b134b8cd51787a7e78753aBen Komalo * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) 3169ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}. 317a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * 318a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * @param options A combination of the bits defined by the DISPLAY_ constants 319a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * defined in ActionBar. 320a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * @param mask A bit mask declaring which display options should be changed. 321a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell */ 322a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell public abstract void setDisplayOptions(int options, int mask); 323a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell 324a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell /** 32533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Set the ActionBar's background. 32633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 32733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param d Background drawable 32833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 32933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract void setBackgroundDrawable(Drawable d); 33033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 33133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 33233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current custom navigation view. 333ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @deprecated Method has been renamed. Use {@link #getCustomView()}. 33433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 335ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell @Deprecated 33633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract View getCustomNavigationView(); 337ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell 338ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell /** 339ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell * @return The current custom view. 340ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell */ 341ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell public abstract View getCustomView(); 342ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell 34333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 344a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current ActionBar title in standard mode. 345a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns null if {@link #getNavigationMode()} would not return 346a408291e22def5755559f42cde913706a6d628c0Adam Powell * {@link #NAVIGATION_MODE_STANDARD}. 347a408291e22def5755559f42cde913706a6d628c0Adam Powell * 348a408291e22def5755559f42cde913706a6d628c0Adam Powell * @return The current ActionBar title or null. 34933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 35033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract CharSequence getTitle(); 35133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 35233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 353a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current ActionBar subtitle in standard mode. 354a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns null if {@link #getNavigationMode()} would not return 355a408291e22def5755559f42cde913706a6d628c0Adam Powell * {@link #NAVIGATION_MODE_STANDARD}. 356a408291e22def5755559f42cde913706a6d628c0Adam Powell * 357a408291e22def5755559f42cde913706a6d628c0Adam Powell * @return The current ActionBar subtitle or null. 35833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 35933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract CharSequence getSubtitle(); 36033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 36133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 362a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current navigation mode. The result will be one of: 363a408291e22def5755559f42cde913706a6d628c0Adam Powell * <ul> 364a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_STANDARD}</li> 3659ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * <li>{@link #NAVIGATION_MODE_LIST}</li> 366a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_TABS}</li> 367a408291e22def5755559f42cde913706a6d628c0Adam Powell * </ul> 368a408291e22def5755559f42cde913706a6d628c0Adam Powell * 36933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current navigation mode. 370a408291e22def5755559f42cde913706a6d628c0Adam Powell * 371661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #setStandardNavigationMode() 372a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setStandardNavigationMode(CharSequence) 373a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setStandardNavigationMode(CharSequence, CharSequence) 374a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setDropdownNavigationMode(SpinnerAdapter) 375661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #setTabNavigationMode() 376a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setCustomNavigationMode(View) 37733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 37833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract int getNavigationMode(); 3799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 3809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 3819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Set the current navigation mode. 3829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 3839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param mode The new mode to set. 3849ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #NAVIGATION_MODE_STANDARD 3859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #NAVIGATION_MODE_LIST 3869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see #NAVIGATION_MODE_TABS 3879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 3889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void setNavigationMode(int mode); 3899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 39033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 39133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current set of display options. 39233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 39333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract int getDisplayOptions(); 394661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 395661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 396661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the action bar into tabbed navigation mode. 397661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 398661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #addTab(Tab) 399661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #insertTab(Tab, int) 400661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #removeTab(Tab) 401661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #removeTabAt(int) 4029ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 4039ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @deprecated See {@link #setNavigationMode(int)} 404661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 405661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void setTabNavigationMode(); 406661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 407661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 408661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Create and return a new {@link Tab}. 409661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * This tab will not be included in the action bar until it is added. 410661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 411661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return A new Tab 412661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 413661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #addTab(Tab) 414661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #insertTab(Tab, int) 415661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 416661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract Tab newTab(); 417661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 418661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 419661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. 42081b8944131946e451b31665652de8cc71d81ea07Adam Powell * If this is the first tab to be added it will become the selected tab. 421661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 422661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab Tab to add 423661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 424661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void addTab(Tab tab); 425661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 426661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 42781b8944131946e451b31665652de8cc71d81ea07Adam Powell * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. 42881b8944131946e451b31665652de8cc71d81ea07Adam Powell * 42981b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param tab Tab to add 43081b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param setSelected True if the added tab should become the selected tab. 43181b8944131946e451b31665652de8cc71d81ea07Adam Powell */ 43281b8944131946e451b31665652de8cc71d81ea07Adam Powell public abstract void addTab(Tab tab, boolean setSelected); 43381b8944131946e451b31665652de8cc71d81ea07Adam Powell 43481b8944131946e451b31665652de8cc71d81ea07Adam Powell /** 4352b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Add a tab for use in tabbed navigation mode. The tab will be inserted at 43681b8944131946e451b31665652de8cc71d81ea07Adam Powell * <code>position</code>. If this is the first tab to be added it will become 43781b8944131946e451b31665652de8cc71d81ea07Adam Powell * the selected tab. 438661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 439661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab The tab to add 440661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param position The new position of the tab 441661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 4422b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract void addTab(Tab tab, int position); 443661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 444661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 44581b8944131946e451b31665652de8cc71d81ea07Adam Powell * Add a tab for use in tabbed navigation mode. The tab will be insterted at 44681b8944131946e451b31665652de8cc71d81ea07Adam Powell * <code>position</code>. 44781b8944131946e451b31665652de8cc71d81ea07Adam Powell * 44881b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param tab The tab to add 44981b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param position The new position of the tab 45081b8944131946e451b31665652de8cc71d81ea07Adam Powell * @param setSelected True if the added tab should become the selected tab. 45181b8944131946e451b31665652de8cc71d81ea07Adam Powell */ 45281b8944131946e451b31665652de8cc71d81ea07Adam Powell public abstract void addTab(Tab tab, int position, boolean setSelected); 45381b8944131946e451b31665652de8cc71d81ea07Adam Powell 45481b8944131946e451b31665652de8cc71d81ea07Adam Powell /** 4559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Remove a tab from the action bar. If the removed tab was selected it will be deselected 4569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * and another tab will be selected if present. 457661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 458661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab The tab to remove 459661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 460661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void removeTab(Tab tab); 461661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 462661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 4639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Remove a tab from the action bar. If the removed tab was selected it will be deselected 4649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * and another tab will be selected if present. 465661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 466661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param position Position of the tab to remove 467661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 468661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void removeTabAt(int position); 469661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 470661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 4719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Remove all tabs from the action bar and deselect the current tab. 4729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 4739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract void removeAllTabs(); 4749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 4759ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 476661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Select the specified tab. If it is not a child of this action bar it will be added. 477661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 4789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p> 4799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 480661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab Tab to select 481661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 482661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void selectTab(Tab tab); 483661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 484661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 4852b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Returns the currently selected tab if in tabbed navigation mode and there is at least 4862b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * one tab present. 4872b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 4882b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return The currently selected tab or null 4892b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 4902b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract Tab getSelectedTab(); 4912b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 4922b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 4939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Returns the tab at the specified index. 4949ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 4959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @param index Index value in the range 0-get 4969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return 4979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 4989ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab getTabAt(int index); 4999ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 5009ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 5010c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * Returns the number of tabs currently registered with the action bar. 5020c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * @return Tab count 5030c24a5514c1ff143a223720a090b19a86a75945fAdam Powell */ 5040c24a5514c1ff143a223720a090b19a86a75945fAdam Powell public abstract int getTabCount(); 5050c24a5514c1ff143a223720a090b19a86a75945fAdam Powell 5060c24a5514c1ff143a223720a090b19a86a75945fAdam Powell /** 5076b336f835d637853800b94689375a03f337139a4Adam Powell * Retrieve the current height of the ActionBar. 5086b336f835d637853800b94689375a03f337139a4Adam Powell * 5096b336f835d637853800b94689375a03f337139a4Adam Powell * @return The ActionBar's height 5106b336f835d637853800b94689375a03f337139a4Adam Powell */ 5116b336f835d637853800b94689375a03f337139a4Adam Powell public abstract int getHeight(); 5126b336f835d637853800b94689375a03f337139a4Adam Powell 5136b336f835d637853800b94689375a03f337139a4Adam Powell /** 5146b336f835d637853800b94689375a03f337139a4Adam Powell * Show the ActionBar if it is not currently showing. 5156b336f835d637853800b94689375a03f337139a4Adam Powell * If the window hosting the ActionBar does not have the feature 5166b336f835d637853800b94689375a03f337139a4Adam Powell * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application 5176b336f835d637853800b94689375a03f337139a4Adam Powell * content to fit the new space available. 5186b336f835d637853800b94689375a03f337139a4Adam Powell */ 5196b336f835d637853800b94689375a03f337139a4Adam Powell public abstract void show(); 5206b336f835d637853800b94689375a03f337139a4Adam Powell 5216b336f835d637853800b94689375a03f337139a4Adam Powell /** 5226b336f835d637853800b94689375a03f337139a4Adam Powell * Hide the ActionBar if it is not currently showing. 5236b336f835d637853800b94689375a03f337139a4Adam Powell * If the window hosting the ActionBar does not have the feature 5246b336f835d637853800b94689375a03f337139a4Adam Powell * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application 5256b336f835d637853800b94689375a03f337139a4Adam Powell * content to fit the new space available. 5266b336f835d637853800b94689375a03f337139a4Adam Powell */ 5276b336f835d637853800b94689375a03f337139a4Adam Powell public abstract void hide(); 5286b336f835d637853800b94689375a03f337139a4Adam Powell 5296b336f835d637853800b94689375a03f337139a4Adam Powell /** 5306b336f835d637853800b94689375a03f337139a4Adam Powell * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise. 5316b336f835d637853800b94689375a03f337139a4Adam Powell */ 5326b336f835d637853800b94689375a03f337139a4Adam Powell public abstract boolean isShowing(); 5336b336f835d637853800b94689375a03f337139a4Adam Powell 5346b336f835d637853800b94689375a03f337139a4Adam Powell /** 5358515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Add a listener that will respond to menu visibility change events. 5368515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * 5378515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param listener The new listener to add 5388515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 5398515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener); 5408515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell 5418515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 5428515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Remove a menu visibility listener. This listener will no longer receive menu 5438515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * visibility change events. 5448515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * 5458515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param listener A listener to remove that was previously added 5468515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 5478515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener); 5488515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell 5498515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 5508515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Listener interface for ActionBar navigation events. 55189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 5528515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public interface OnNavigationListener { 55389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 55489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * This method is called whenever a navigation item in your action bar 55589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * is selected. 55689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 55789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param itemPosition Position of the item clicked. 55889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param itemId ID of the item clicked. 55989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @return True if the event was handled, false otherwise. 56089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 56189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public boolean onNavigationItemSelected(int itemPosition, long itemId); 56233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell } 563661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 564661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 5658515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Listener for receiving events when action bar menus are shown or hidden. 5668515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 5678515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public interface OnMenuVisibilityListener { 5688515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 5698515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * Called when an action bar menu is shown or hidden. Applications may want to use 5708515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * this to tune auto-hiding behavior for the action bar or pause/resume video playback, 5718515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * gameplay, or other activity within the main content area. 5728515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * 5738515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * @param isVisible True if an action bar menu is now visible, false if no action bar 5748515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell * menus are visible. 5758515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell */ 5768515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell public void onMenuVisibilityChanged(boolean isVisible); 5778515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell } 5788515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell 5798515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell /** 580661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * A tab in the action bar. 581661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 582661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * <p>Tabs manage the hiding and showing of {@link Fragment}s. 583661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 584661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public static abstract class Tab { 585661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 586661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * An invalid position for a tab. 587661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 588661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #getPosition() 589661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 590661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public static final int INVALID_POSITION = -1; 591661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 592661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 593661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the current position of this tab in the action bar. 594661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 595661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in 596661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * the action bar. 597661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 598661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract int getPosition(); 599661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 600661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 601661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the icon associated with this tab. 602661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 603661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return The tab's icon 604661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 605661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract Drawable getIcon(); 606661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 607661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 608661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the text of this tab. 609661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 610661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return The tab's text 611661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 612661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract CharSequence getText(); 613661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 614661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 615661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the icon displayed on this tab. 616661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 617661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param icon The drawable to use as an icon 6189ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 619661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 6209ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setIcon(Drawable icon); 621661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 622661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 62332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * Set the icon displayed on this tab. 62432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * 62532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @param resId Resource ID referring to the drawable to use as an icon 62632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @return The current instance for call chaining 62732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell */ 62832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell public abstract Tab setIcon(int resId); 62932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell 63032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell /** 631661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the text displayed on this tab. Text may be truncated if there is not 632661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * room to display the entire string. 633661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 634661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param text The text to display 6359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 636661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 6379ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setText(CharSequence text); 638661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 639661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 64032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * Set the text displayed on this tab. Text may be truncated if there is not 64132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * room to display the entire string. 64232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * 64332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @param resId A resource ID referring to the text that should be displayed 64432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @return The current instance for call chaining 64532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell */ 64632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell public abstract Tab setText(int resId); 64732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell 64832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell /** 6492b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Set a custom view to be used for this tab. This overrides values set by 6502b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. 651661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 6522b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param view Custom view to be used as a tab. 6539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 654661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 6559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setCustomView(View view); 656661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 657661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 65832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * Set a custom view to be used for this tab. This overrides values set by 65932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}. 66032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * 66132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @param layoutResId A layout resource to inflate and use as a custom tab view 66232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell * @return The current instance for call chaining 66332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell */ 66432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell public abstract Tab setCustomView(int layoutResId); 66532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell 66632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell /** 6672b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Retrieve a previously set custom view for this tab. 668661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 6692b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return The custom view set by {@link #setCustomView(View)}. 670661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 6712b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract View getCustomView(); 6722b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 6732b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 6742b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Give this Tab an arbitrary object to hold for later use. 6752b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 6762b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param obj Object to store 6779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 6782b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 6799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setTag(Object obj); 6802b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 6812b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 6822b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return This Tab's tag object. 6832b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 6842b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public abstract Object getTag(); 6852b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 6862b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 6872b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Set the {@link TabListener} that will handle switching to and from this tab. 6882b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * All tabs must have a TabListener set before being added to the ActionBar. 6892b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 6902b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param listener Listener to handle tab selection events 6919ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @return The current instance for call chaining 6922b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 6939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public abstract Tab setTabListener(TabListener listener); 694661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 695661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 696661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Select this tab. Only valid if the tab has been added to the action bar. 697661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 698661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void select(); 699661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell } 7002b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 7012b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7022b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Callback interface invoked when a tab is focused, unfocused, added, or removed. 7032b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7042b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public interface TabListener { 7052b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7062b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Called when a tab enters the selected state. 7072b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 7082b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param tab The tab that was selected 7092b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute 7102b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * during a tab switch. The previous tab's unselect and this tab's select will be 7110c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * executed in a single transaction. This FragmentTransaction does not support 7120c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * being added to the back stack. 7132b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7142b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public void onTabSelected(Tab tab, FragmentTransaction ft); 7152b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 7162b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 7172b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * Called when a tab exits the selected state. 7182b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * 7192b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param tab The tab that was unselected 7202b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute 7212b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * during a tab switch. This tab's unselect and the newly selected tab's select 7220c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * will be executed in a single transaction. This FragmentTransaction does not 7230c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * support being added to the back stack. 7242b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 7252b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell public void onTabUnselected(Tab tab, FragmentTransaction ft); 7267f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell 7277f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell /** 7287f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * Called when a tab that is already selected is chosen again by the user. 7297f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * Some applications may use this action to return to the top level of a category. 7307f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * 7317f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * @param tab The tab that was reselected. 7327f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute 7330c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * once this method returns. This FragmentTransaction does not support 7340c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * being added to the back stack. 7357f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell */ 7367f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell public void onTabReselected(Tab tab, FragmentTransaction ft); 7372b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell } 7389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 7409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Per-child layout information associated with action bar custom views. 7419ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 7429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity 7439ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 7449ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public static class LayoutParams extends MarginLayoutParams { 7459ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell /** 7469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * Gravity for the view associated with these LayoutParams. 7479ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * 7489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell * @see android.view.Gravity 7499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell */ 7509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.ExportedProperty(category = "layout", mapping = { 7519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = -1, to = "NONE"), 7529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"), 7539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"), 7549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"), 7559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"), 7569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"), 7579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"), 7589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"), 7599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"), 7609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"), 7619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"), 7629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL") 7639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell }) 7649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public int gravity = -1; 7659ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7669ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(Context c, AttributeSet attrs) { 7679ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(c, attrs); 7689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell TypedArray a = c.obtainStyledAttributes(attrs, 7709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell com.android.internal.R.styleable.ActionBar_LayoutParams); 7719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell gravity = a.getInt( 7729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell com.android.internal.R.styleable.ActionBar_LayoutParams_layout_gravity, -1); 7739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7759ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(int width, int height) { 7769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(width, height); 7779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; 7789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(int width, int height, int gravity) { 7819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(width, height); 7829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this.gravity = gravity; 7839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7849ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(int gravity) { 7869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this(WRAP_CONTENT, MATCH_PARENT, gravity); 7879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(LayoutParams source) { 7909ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(source); 7919ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell this.gravity = source.gravity; 7939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7949ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell 7959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell public LayoutParams(ViewGroup.LayoutParams source) { 7969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell super(source); 7979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 7989ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell } 79933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell} 800