ActionBar.java revision 3f476b34049d062942eafcf48396f593e00bd324
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    /**
1573f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set the action bar into custom navigation mode, supplying a view
1583f476b34049d062942eafcf48396f593e00bd324Adam Powell     * for custom navigation.
1593f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
1603f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>Custom navigation views appear between the application icon and
1613f476b34049d062942eafcf48396f593e00bd324Adam Powell     * any action buttons and may use any space available there. Common
1623f476b34049d062942eafcf48396f593e00bd324Adam Powell     * use cases for custom navigation views might include an auto-suggesting
1633f476b34049d062942eafcf48396f593e00bd324Adam Powell     * address bar for a browser or other navigation mechanisms that do not
1643f476b34049d062942eafcf48396f593e00bd324Adam Powell     * translate well to provided navigation modes.</p>
1653f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
1663f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
1673f476b34049d062942eafcf48396f593e00bd324Adam Powell     * the custom view to be displayed.</p>
1683f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
1693f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param resId Resource ID of a layout to inflate into the ActionBar.
1703f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
1713f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
1723f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
1733f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setCustomView(int resId);
1743f476b34049d062942eafcf48396f593e00bd324Adam Powell
1753f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
1769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @param view
1779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @deprecated Use {@link #setCustomView(View)} and {@link #setDisplayOptions(int)} instead.
1789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
1799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    @Deprecated
180a408291e22def5755559f42cde913706a6d628c0Adam Powell    public abstract void setCustomNavigationMode(View view);
18133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell
18233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
183a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Set the action bar into dropdown navigation mode and supply an adapter
184a408291e22def5755559f42cde913706a6d628c0Adam Powell     * that will provide views for navigation choices.
18533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     *
186a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @param adapter An adapter that will provide views both to display
187a408291e22def5755559f42cde913706a6d628c0Adam Powell     *                the current navigation selection and populate views
188a408291e22def5755559f42cde913706a6d628c0Adam Powell     *                within the dropdown navigation menu.
1898515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * @param callback A OnNavigationListener that will receive events when the user
19089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell     *                 selects a navigation item.
1919ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @deprecated See setListNavigationCallbacks.
19233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
1939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    @Deprecated
19489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell    public abstract void setDropdownNavigationMode(SpinnerAdapter adapter,
1958515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell            OnNavigationListener callback);
196a408291e22def5755559f42cde913706a6d628c0Adam Powell
19733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
1989ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Set the adapter and navigation callback for list navigation mode.
1999ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
2009ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * The supplied adapter will provide views for the expanded list as well as
2019ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * the currently selected item. (These may be displayed differently.)
2029ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
2038515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * The supplied OnNavigationListener will alert the application when the user
2049ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * changes the current list selection.
2059ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
2069ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @param adapter An adapter that will provide views both to display
2079ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *                the current navigation selection and populate views
2089ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *                within the dropdown navigation menu.
2098515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * @param callback An OnNavigationListener that will receive events when the user
2109ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *                 selects a navigation item.
2119ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
2129ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract void setListNavigationCallbacks(SpinnerAdapter adapter,
2138515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell            OnNavigationListener callback);
2149ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
2159ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
216178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     * Set the action bar into dropdown navigation mode and supply an adapter that will
217178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     * provide views for navigation choices.
218178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     *
219178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     * @param adapter An adapter that will provide views both to display the current
220178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     *                navigation selection and populate views within the dropdown
221178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     *                navigation menu.
2228515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * @param callback A OnNavigationListener that will receive events when the user
223178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     *                 selects a navigation item.
224178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     * @param defaultSelectedPosition Position within the provided adapter that should be
225178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     *                                selected from the outset.
2269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @deprecated See setListNavigationCallbacks and setSelectedNavigationItem.
227178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     */
2289ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    @Deprecated
229178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell    public abstract void setDropdownNavigationMode(SpinnerAdapter adapter,
2308515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell            OnNavigationListener callback, int defaultSelectedPosition);
231178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell
232178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell    /**
2339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Set the selected navigation item in list or tabbed navigation modes.
234178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     *
235178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     * @param position Position of the item to select.
236178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     */
237178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell    public abstract void setSelectedNavigationItem(int position);
238178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell
239178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell    /**
2409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Get the position of the selected navigation item in list or tabbed navigation modes.
241178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     *
242178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     * @return Position of the selected item.
2439ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @deprecated Use {@link #getSelectedNavigationIndex()} instead.
244178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     */
2459ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    @Deprecated
246178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell    public abstract int getSelectedNavigationItem();
247178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell
248178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell    /**
2499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Get the position of the selected navigation item in list or tabbed navigation modes.
2509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
2519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @return Position of the selected item.
2529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
2539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract int getSelectedNavigationIndex();
2549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
2559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
2569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Get the number of navigation items present in the current navigation mode.
2579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
2589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @return Number of navigation items.
2599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
2609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract int getNavigationItemCount();
2619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
2629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
2630e94b5151d817e600a888448a662208b29b5ef46Adam Powell     * Set the action bar into standard navigation mode, using the currently set title
2640e94b5151d817e600a888448a662208b29b5ef46Adam Powell     * and/or subtitle.
2650e94b5151d817e600a888448a662208b29b5ef46Adam Powell     *
2660e94b5151d817e600a888448a662208b29b5ef46Adam Powell     * Standard navigation mode is default. The title is automatically set to the name of
2670e94b5151d817e600a888448a662208b29b5ef46Adam Powell     * your Activity on startup if an action bar is present.
2689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @deprecated See setNavigationMode
2690e94b5151d817e600a888448a662208b29b5ef46Adam Powell     */
2709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    @Deprecated
2710e94b5151d817e600a888448a662208b29b5ef46Adam Powell    public abstract void setStandardNavigationMode();
2720e94b5151d817e600a888448a662208b29b5ef46Adam Powell
2730e94b5151d817e600a888448a662208b29b5ef46Adam Powell    /**
274ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * Set the action bar's title. This will only be displayed if
275ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * {@link #DISPLAY_SHOW_TITLE} is set.
2760e94b5151d817e600a888448a662208b29b5ef46Adam Powell     *
2770e94b5151d817e600a888448a662208b29b5ef46Adam Powell     * @param title Title to set
278a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
279a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @see #setTitle(int)
280ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @see #setDisplayOptions(int, int)
2810e94b5151d817e600a888448a662208b29b5ef46Adam Powell     */
2820e94b5151d817e600a888448a662208b29b5ef46Adam Powell    public abstract void setTitle(CharSequence title);
2830e94b5151d817e600a888448a662208b29b5ef46Adam Powell
2840e94b5151d817e600a888448a662208b29b5ef46Adam Powell    /**
285ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * Set the action bar's title. This will only be displayed if
286ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * {@link #DISPLAY_SHOW_TITLE} is set.
287a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
288a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @param resId Resource ID of title string to set
289a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
290a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @see #setTitle(CharSequence)
291ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @see #setDisplayOptions(int, int)
292a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     */
293a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell    public abstract void setTitle(int resId);
294a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell
295a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell    /**
296ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * Set the action bar's subtitle. This will only be displayed if
297ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the
298ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * subtitle entirely.
2990e94b5151d817e600a888448a662208b29b5ef46Adam Powell     *
3000e94b5151d817e600a888448a662208b29b5ef46Adam Powell     * @param subtitle Subtitle to set
301a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
302a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @see #setSubtitle(int)
303ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @see #setDisplayOptions(int, int)
3040e94b5151d817e600a888448a662208b29b5ef46Adam Powell     */
3050e94b5151d817e600a888448a662208b29b5ef46Adam Powell    public abstract void setSubtitle(CharSequence subtitle);
3060e94b5151d817e600a888448a662208b29b5ef46Adam Powell
3070e94b5151d817e600a888448a662208b29b5ef46Adam Powell    /**
308ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * Set the action bar's subtitle. This will only be displayed if
309ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * {@link #DISPLAY_SHOW_TITLE} is set.
310a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
311a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @param resId Resource ID of subtitle string to set
312a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
313a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @see #setSubtitle(CharSequence)
314ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @see #setDisplayOptions(int, int)
315a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     */
316a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell    public abstract void setSubtitle(int resId);
317a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell
318a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell    /**
319a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * Set display options. This changes all display option bits at once. To change
320a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * a limited subset of display options, see {@link #setDisplayOptions(int, int)}.
32133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     *
32233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @param options A combination of the bits defined by the DISPLAY_ constants
32333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     *                defined in ActionBar.
32433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
32533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract void setDisplayOptions(int options);
32633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell
32733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
328a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * Set selected display options. Only the options specified by mask will be changed.
329a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * To change all display option bits at once, see {@link #setDisplayOptions(int)}.
330a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     *
3319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the
3329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * {@link #DISPLAY_SHOW_HOME} option.
3335ad7af6fc764f71765b134b8cd51787a7e78753aBen Komalo     * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)
3349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}.
335a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     *
336a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * @param options A combination of the bits defined by the DISPLAY_ constants
337a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     *                defined in ActionBar.
338a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * @param mask A bit mask declaring which display options should be changed.
339a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     */
340a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell    public abstract void setDisplayOptions(int options, int mask);
3413f476b34049d062942eafcf48396f593e00bd324Adam Powell
3423f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3433f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether to display the activity logo rather than the activity icon.
3443f476b34049d062942eafcf48396f593e00bd324Adam Powell     * A logo is often a wider, more detailed image.
3453f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3463f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3473f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3483f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param useLogo true to use the activity logo, false to use the activity icon.
3493f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3503f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
3513f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
3523f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
3533f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayUseLogoEnabled(boolean useLogo);
3543f476b34049d062942eafcf48396f593e00bd324Adam Powell
3553f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3563f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether to include the application home affordance in the action bar.
3573f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Home is presented as either an activity icon or logo.
3583f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3593f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3603f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3613f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param showHome true to show home, false otherwise.
3623f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3633f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
3643f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
3653f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
3663f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayShowHomeEnabled(boolean showHome);
3673f476b34049d062942eafcf48396f593e00bd324Adam Powell
3683f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3693f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether home should be displayed as an "up" affordance.
3703f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set this to true if selecting "home" returns up by a single level in your UI
3713f476b34049d062942eafcf48396f593e00bd324Adam Powell     * rather than back to the top level or front page.
3723f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3733f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3743f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3753f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param showHomeAsUp true to show the user that selecting home will return one
3763f476b34049d062942eafcf48396f593e00bd324Adam Powell     *                     level up rather than to the top level of the app.
3773f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3783f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
3793f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
3803f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
3813f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
3823f476b34049d062942eafcf48396f593e00bd324Adam Powell
3833f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3843f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether an activity title/subtitle should be displayed.
3853f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3863f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3873f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3883f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param showTitle true to display a title/subtitle if present.
3893f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3903f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
3913f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
3923f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
3933f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayShowTitleEnabled(boolean showTitle);
3943f476b34049d062942eafcf48396f593e00bd324Adam Powell
3953f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3963f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether a custom view should be displayed, if set.
3973f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3983f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3993f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
4003f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param showCustom true if the currently set custom view should be displayed, false otherwise.
4013f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
4023f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
4033f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
4043f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
4053f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayShowCustomEnabled(boolean showCustom);
4063f476b34049d062942eafcf48396f593e00bd324Adam Powell
407a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell    /**
40833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * Set the ActionBar's background.
40933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     *
41033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @param d Background drawable
41133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
41233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract void setBackgroundDrawable(Drawable d);
41333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell
41433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
41533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @return The current custom navigation view.
416ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @deprecated Method has been renamed. Use {@link #getCustomView()}.
41733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
418ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell    @Deprecated
41933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract View getCustomNavigationView();
420ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell
421ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell    /**
422ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @return The current custom view.
423ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     */
424ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell    public abstract View getCustomView();
425ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell
42633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
427a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns the current ActionBar title in standard mode.
428a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns null if {@link #getNavigationMode()} would not return
429a408291e22def5755559f42cde913706a6d628c0Adam Powell     * {@link #NAVIGATION_MODE_STANDARD}.
430a408291e22def5755559f42cde913706a6d628c0Adam Powell     *
431a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @return The current ActionBar title or null.
43233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
43333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract CharSequence getTitle();
43433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell
43533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
436a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns the current ActionBar subtitle in standard mode.
437a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns null if {@link #getNavigationMode()} would not return
438a408291e22def5755559f42cde913706a6d628c0Adam Powell     * {@link #NAVIGATION_MODE_STANDARD}.
439a408291e22def5755559f42cde913706a6d628c0Adam Powell     *
440a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @return The current ActionBar subtitle or null.
44133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
44233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract CharSequence getSubtitle();
44333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell
44433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
445a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns the current navigation mode. The result will be one of:
446a408291e22def5755559f42cde913706a6d628c0Adam Powell     * <ul>
447a408291e22def5755559f42cde913706a6d628c0Adam Powell     * <li>{@link #NAVIGATION_MODE_STANDARD}</li>
4489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * <li>{@link #NAVIGATION_MODE_LIST}</li>
449a408291e22def5755559f42cde913706a6d628c0Adam Powell     * <li>{@link #NAVIGATION_MODE_TABS}</li>
450a408291e22def5755559f42cde913706a6d628c0Adam Powell     * </ul>
451a408291e22def5755559f42cde913706a6d628c0Adam Powell     *
45233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @return The current navigation mode.
453a408291e22def5755559f42cde913706a6d628c0Adam Powell     *
454661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #setStandardNavigationMode()
455a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @see #setStandardNavigationMode(CharSequence)
456a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @see #setStandardNavigationMode(CharSequence, CharSequence)
457a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @see #setDropdownNavigationMode(SpinnerAdapter)
458661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #setTabNavigationMode()
459a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @see #setCustomNavigationMode(View)
46033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
46133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract int getNavigationMode();
4629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
4639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
4649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Set the current navigation mode.
4659ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
4669ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @param mode The new mode to set.
4679ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #NAVIGATION_MODE_STANDARD
4689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #NAVIGATION_MODE_LIST
4699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #NAVIGATION_MODE_TABS
4709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
4719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract void setNavigationMode(int mode);
4729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
47333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
47433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @return The current set of display options.
47533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
47633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract int getDisplayOptions();
477661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
478661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
479661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * Set the action bar into tabbed navigation mode.
480661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
481661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #addTab(Tab)
482661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #insertTab(Tab, int)
483661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #removeTab(Tab)
484661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #removeTabAt(int)
4859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
4869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @deprecated See {@link #setNavigationMode(int)}
487661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
488661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract void setTabNavigationMode();
489661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
490661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
491661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * Create and return a new {@link Tab}.
492661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * This tab will not be included in the action bar until it is added.
493661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
494661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @return A new Tab
495661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
496661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #addTab(Tab)
497661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #insertTab(Tab, int)
498661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
499661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract Tab newTab();
500661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
501661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
502661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
50381b8944131946e451b31665652de8cc71d81ea07Adam Powell     * If this is the first tab to be added it will become the selected tab.
504661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
505661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param tab Tab to add
506661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
507661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract void addTab(Tab tab);
508661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
509661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
51081b8944131946e451b31665652de8cc71d81ea07Adam Powell     * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
51181b8944131946e451b31665652de8cc71d81ea07Adam Powell     *
51281b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param tab Tab to add
51381b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param setSelected True if the added tab should become the selected tab.
51481b8944131946e451b31665652de8cc71d81ea07Adam Powell     */
51581b8944131946e451b31665652de8cc71d81ea07Adam Powell    public abstract void addTab(Tab tab, boolean setSelected);
51681b8944131946e451b31665652de8cc71d81ea07Adam Powell
51781b8944131946e451b31665652de8cc71d81ea07Adam Powell    /**
5182b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * Add a tab for use in tabbed navigation mode. The tab will be inserted at
51981b8944131946e451b31665652de8cc71d81ea07Adam Powell     * <code>position</code>. If this is the first tab to be added it will become
52081b8944131946e451b31665652de8cc71d81ea07Adam Powell     * the selected tab.
521661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
522661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param tab The tab to add
523661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param position The new position of the tab
524661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
5252b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    public abstract void addTab(Tab tab, int position);
526661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
527661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
52881b8944131946e451b31665652de8cc71d81ea07Adam Powell     * Add a tab for use in tabbed navigation mode. The tab will be insterted at
52981b8944131946e451b31665652de8cc71d81ea07Adam Powell     * <code>position</code>.
53081b8944131946e451b31665652de8cc71d81ea07Adam Powell     *
53181b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param tab The tab to add
53281b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param position The new position of the tab
53381b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param setSelected True if the added tab should become the selected tab.
53481b8944131946e451b31665652de8cc71d81ea07Adam Powell     */
53581b8944131946e451b31665652de8cc71d81ea07Adam Powell    public abstract void addTab(Tab tab, int position, boolean setSelected);
53681b8944131946e451b31665652de8cc71d81ea07Adam Powell
53781b8944131946e451b31665652de8cc71d81ea07Adam Powell    /**
5389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Remove a tab from the action bar. If the removed tab was selected it will be deselected
5399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * and another tab will be selected if present.
540661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
541661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param tab The tab to remove
542661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
543661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract void removeTab(Tab tab);
544661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
545661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
5469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Remove a tab from the action bar. If the removed tab was selected it will be deselected
5479ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * and another tab will be selected if present.
548661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
549661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param position Position of the tab to remove
550661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
551661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract void removeTabAt(int position);
552661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
553661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
5549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Remove all tabs from the action bar and deselect the current tab.
5559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
5569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract void removeAllTabs();
5579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
5589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
559661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * Select the specified tab. If it is not a child of this action bar it will be added.
560661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
5619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p>
5629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
563661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param tab Tab to select
564661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
565661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract void selectTab(Tab tab);
566661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
567661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
5682b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * Returns the currently selected tab if in tabbed navigation mode and there is at least
5692b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * one tab present.
5702b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     *
5712b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * @return The currently selected tab or null
5722b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     */
5732b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    public abstract Tab getSelectedTab();
5742b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
5752b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    /**
5769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Returns the tab at the specified index.
5779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
5789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @param index Index value in the range 0-get
5799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @return
5809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
5819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract Tab getTabAt(int index);
5829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
5839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
5840c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * Returns the number of tabs currently registered with the action bar.
5850c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * @return Tab count
5860c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     */
5870c24a5514c1ff143a223720a090b19a86a75945fAdam Powell    public abstract int getTabCount();
5880c24a5514c1ff143a223720a090b19a86a75945fAdam Powell
5890c24a5514c1ff143a223720a090b19a86a75945fAdam Powell    /**
5906b336f835d637853800b94689375a03f337139a4Adam Powell     * Retrieve the current height of the ActionBar.
5916b336f835d637853800b94689375a03f337139a4Adam Powell     *
5926b336f835d637853800b94689375a03f337139a4Adam Powell     * @return The ActionBar's height
5936b336f835d637853800b94689375a03f337139a4Adam Powell     */
5946b336f835d637853800b94689375a03f337139a4Adam Powell    public abstract int getHeight();
5956b336f835d637853800b94689375a03f337139a4Adam Powell
5966b336f835d637853800b94689375a03f337139a4Adam Powell    /**
5976b336f835d637853800b94689375a03f337139a4Adam Powell     * Show the ActionBar if it is not currently showing.
5986b336f835d637853800b94689375a03f337139a4Adam Powell     * If the window hosting the ActionBar does not have the feature
5996b336f835d637853800b94689375a03f337139a4Adam Powell     * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
6006b336f835d637853800b94689375a03f337139a4Adam Powell     * content to fit the new space available.
6016b336f835d637853800b94689375a03f337139a4Adam Powell     */
6026b336f835d637853800b94689375a03f337139a4Adam Powell    public abstract void show();
6036b336f835d637853800b94689375a03f337139a4Adam Powell
6046b336f835d637853800b94689375a03f337139a4Adam Powell    /**
6056b336f835d637853800b94689375a03f337139a4Adam Powell     * Hide the ActionBar if it is not currently showing.
6066b336f835d637853800b94689375a03f337139a4Adam Powell     * If the window hosting the ActionBar does not have the feature
6076b336f835d637853800b94689375a03f337139a4Adam Powell     * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
6086b336f835d637853800b94689375a03f337139a4Adam Powell     * content to fit the new space available.
6096b336f835d637853800b94689375a03f337139a4Adam Powell     */
6106b336f835d637853800b94689375a03f337139a4Adam Powell    public abstract void hide();
6116b336f835d637853800b94689375a03f337139a4Adam Powell
6126b336f835d637853800b94689375a03f337139a4Adam Powell    /**
6136b336f835d637853800b94689375a03f337139a4Adam Powell     * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise.
6146b336f835d637853800b94689375a03f337139a4Adam Powell     */
6156b336f835d637853800b94689375a03f337139a4Adam Powell    public abstract boolean isShowing();
6166b336f835d637853800b94689375a03f337139a4Adam Powell
6176b336f835d637853800b94689375a03f337139a4Adam Powell    /**
6188515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * Add a listener that will respond to menu visibility change events.
6198515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     *
6208515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * @param listener The new listener to add
6218515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     */
6228515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener);
6238515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell
6248515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    /**
6258515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * Remove a menu visibility listener. This listener will no longer receive menu
6268515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * visibility change events.
6278515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     *
6288515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * @param listener A listener to remove that was previously added
6298515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     */
6308515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener);
6318515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell
6328515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    /**
6338515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * Listener interface for ActionBar navigation events.
63489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell     */
6358515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    public interface OnNavigationListener {
63689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell        /**
63789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * This method is called whenever a navigation item in your action bar
63889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * is selected.
63989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         *
64089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * @param itemPosition Position of the item clicked.
64189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * @param itemId ID of the item clicked.
64289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * @return True if the event was handled, false otherwise.
64389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         */
64489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell        public boolean onNavigationItemSelected(int itemPosition, long itemId);
64533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    }
646661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
647661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
6488515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * Listener for receiving events when action bar menus are shown or hidden.
6498515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     */
6508515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    public interface OnMenuVisibilityListener {
6518515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell        /**
6528515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         * Called when an action bar menu is shown or hidden. Applications may want to use
6538515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         * this to tune auto-hiding behavior for the action bar or pause/resume video playback,
6548515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         * gameplay, or other activity within the main content area.
6558515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         *
6568515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         * @param isVisible True if an action bar menu is now visible, false if no action bar
6578515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         *                  menus are visible.
6588515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         */
6598515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell        public void onMenuVisibilityChanged(boolean isVisible);
6608515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    }
6618515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell
6628515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    /**
663661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * A tab in the action bar.
664661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
665661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * <p>Tabs manage the hiding and showing of {@link Fragment}s.
666661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
667661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public static abstract class Tab {
668661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
669661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * An invalid position for a tab.
670661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
671661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @see #getPosition()
672661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
673661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public static final int INVALID_POSITION = -1;
674661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
675661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
676661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Return the current position of this tab in the action bar.
677661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
678661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in
679661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *         the action bar.
680661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
681661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public abstract int getPosition();
682661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
683661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
684661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Return the icon associated with this tab.
685661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
686661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @return The tab's icon
687661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
688661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public abstract Drawable getIcon();
689661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
690661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
691661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Return the text of this tab.
692661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
693661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @return The tab's text
694661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
695661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public abstract CharSequence getText();
696661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
697661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
698661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Set the icon displayed on this tab.
699661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
700661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @param icon The drawable to use as an icon
7019ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
702661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
7039ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setIcon(Drawable icon);
704661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
705661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
70632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * Set the icon displayed on this tab.
70732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         *
70832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @param resId Resource ID referring to the drawable to use as an icon
70932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @return The current instance for call chaining
71032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         */
71132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        public abstract Tab setIcon(int resId);
71232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell
71332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        /**
714661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Set the text displayed on this tab. Text may be truncated if there is not
715661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * room to display the entire string.
716661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
717661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @param text The text to display
7189ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
719661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
7209ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setText(CharSequence text);
721661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
722661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
72332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * Set the text displayed on this tab. Text may be truncated if there is not
72432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * room to display the entire string.
72532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         *
72632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @param resId A resource ID referring to the text that should be displayed
72732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @return The current instance for call chaining
72832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         */
72932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        public abstract Tab setText(int resId);
73032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell
73132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        /**
7322b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Set a custom view to be used for this tab. This overrides values set by
7332b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
734661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
7352b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param view Custom view to be used as a tab.
7369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
737661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
7389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setCustomView(View view);
739661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
740661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
74132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * Set a custom view to be used for this tab. This overrides values set by
74232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
74332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         *
74432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @param layoutResId A layout resource to inflate and use as a custom tab view
74532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @return The current instance for call chaining
74632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         */
74732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        public abstract Tab setCustomView(int layoutResId);
74832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell
74932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        /**
7502b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Retrieve a previously set custom view for this tab.
751661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
7522b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @return The custom view set by {@link #setCustomView(View)}.
753661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
7542b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        public abstract View getCustomView();
7552b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
7562b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
7572b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Give this Tab an arbitrary object to hold for later use.
7582b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *
7592b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param obj Object to store
7609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
7612b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
7629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setTag(Object obj);
7632b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
7642b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
7652b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @return This Tab's tag object.
7662b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
7672b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        public abstract Object getTag();
7682b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
7692b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
7702b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Set the {@link TabListener} that will handle switching to and from this tab.
7712b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * All tabs must have a TabListener set before being added to the ActionBar.
7722b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *
7732b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param listener Listener to handle tab selection events
7749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
7752b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
7769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setTabListener(TabListener listener);
777661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
778661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
779661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Select this tab. Only valid if the tab has been added to the action bar.
780661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
781661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public abstract void select();
782661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    }
7832b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
7842b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    /**
7852b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * Callback interface invoked when a tab is focused, unfocused, added, or removed.
7862b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     */
7872b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    public interface TabListener {
7882b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
7892b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Called when a tab enters the selected state.
7902b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *
7912b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param tab The tab that was selected
7922b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
7932b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *        during a tab switch. The previous tab's unselect and this tab's select will be
7940c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        executed in a single transaction. This FragmentTransaction does not support
7950c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        being added to the back stack.
7962b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
7972b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        public void onTabSelected(Tab tab, FragmentTransaction ft);
7982b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
7992b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
8002b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Called when a tab exits the selected state.
8012b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *
8022b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param tab The tab that was unselected
8032b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
8042b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *        during a tab switch. This tab's unselect and the newly selected tab's select
8050c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        will be executed in a single transaction. This FragmentTransaction does not
8060c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        support being added to the back stack.
8072b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
8082b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        public void onTabUnselected(Tab tab, FragmentTransaction ft);
8097f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell
8107f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell        /**
8117f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         * Called when a tab that is already selected is chosen again by the user.
8127f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         * Some applications may use this action to return to the top level of a category.
8137f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         *
8147f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         * @param tab The tab that was reselected.
8157f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
8160c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        once this method returns. This FragmentTransaction does not support
8170c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        being added to the back stack.
8187f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         */
8197f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell        public void onTabReselected(Tab tab, FragmentTransaction ft);
8202b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    }
8219ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
8239ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Per-child layout information associated with action bar custom views.
8249ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
8259ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity
8269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
8279ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public static class LayoutParams extends MarginLayoutParams {
8289ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        /**
8299ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * Gravity for the view associated with these LayoutParams.
8309ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         *
8319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @see android.view.Gravity
8329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         */
8339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        @ViewDebug.ExportedProperty(category = "layout", mapping = {
8349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from =  -1,                       to = "NONE"),
8359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.NO_GRAVITY,        to = "NONE"),
8369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.TOP,               to = "TOP"),
8379ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.BOTTOM,            to = "BOTTOM"),
8389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.LEFT,              to = "LEFT"),
8399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.RIGHT,             to = "RIGHT"),
8409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL,   to = "CENTER_VERTICAL"),
8419ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL,     to = "FILL_VERTICAL"),
8429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),
8439ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL,   to = "FILL_HORIZONTAL"),
8449ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.CENTER,            to = "CENTER"),
8459ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.FILL,              to = "FILL")
8469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        })
8479ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public int gravity = -1;
8489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(Context c, AttributeSet attrs) {
8509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(c, attrs);
8519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            TypedArray a = c.obtainStyledAttributes(attrs,
8539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell                    com.android.internal.R.styleable.ActionBar_LayoutParams);
8549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            gravity = a.getInt(
8559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell                    com.android.internal.R.styleable.ActionBar_LayoutParams_layout_gravity, -1);
8569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(int width, int height) {
8599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(width, height);
8609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
8619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(int width, int height, int gravity) {
8649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(width, height);
8659ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            this.gravity = gravity;
8669ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8679ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(int gravity) {
8699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            this(WRAP_CONTENT, MATCH_PARENT, gravity);
8709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(LayoutParams source) {
8739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(source);
8749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8759ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            this.gravity = source.gravity;
8769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(ViewGroup.LayoutParams source) {
8799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(source);
8809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    }
88233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell}
883