ActionBar.java revision 88ab69780f58e4b32d497266b2ad646a4d74827b
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/**
3236193d09a87035395d036a730038b765ac0b0913Scott Main * Acts as a replacement for the title bar in Activities.
3336193d09a87035395d036a730038b765ac0b0913Scott Main * The action bar provides facilities for creating toolbar actions as well as
3436193d09a87035395d036a730038b765ac0b0913Scott Main * methods of navigating the application.
3536193d09a87035395d036a730038b765ac0b0913Scott Main * <p>By default, the action bar appears at the top of every activity, with the application icon on
3636193d09a87035395d036a730038b765ac0b0913Scott Main * the left, followed by the activity title. Items from the activity's options menu are also
3736193d09a87035395d036a730038b765ac0b0913Scott Main * accessible from the action bar.</p>
3836193d09a87035395d036a730038b765ac0b0913Scott Main * <p>From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link
3936193d09a87035395d036a730038b765ac0b0913Scott Main * android.app.Activity#getActionBar getActionBar()}.</p>
4036193d09a87035395d036a730038b765ac0b0913Scott Main * <p>For more information, read the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action
4136193d09a87035395d036a730038b765ac0b0913Scott Main * Bar</a> developer guide.</p>
4233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */
4333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellpublic abstract class ActionBar {
44a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell    /**
45a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Standard navigation mode. Consists of either a logo or icon
46a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * and title text with an optional subtitle. Clicking any of these elements
47cf0357639e952a87f0d535c82691919af81f058bAdam Powell     * will dispatch onOptionsItemSelected to the host Activity with
48a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * a MenuItem with item ID android.R.id.home.
49a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     */
50a408291e22def5755559f42cde913706a6d628c0Adam Powell    public static final int NAVIGATION_MODE_STANDARD = 0;
5133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell
5233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * List navigation mode. Instead of static title text this mode
549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * presents a list menu for navigation within the activity.
559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * e.g. this might be presented to the user as a dropdown list.
5633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public static final int NAVIGATION_MODE_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     * Display the 'home' element such that it appears as an 'up' affordance.
859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * e.g. show an arrow to the left indicating the action that will be taken.
869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Set this flag if selecting the 'home' button in the action bar to return
889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * up by a single level in your UI rather than back to the top level or front page.
899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
90c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * <p>Setting this option will implicitly enable interaction with the home/up
91c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * button. See {@link #setHomeButtonEnabled(boolean)}.
92c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     *
939ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setDisplayOptions(int)
949ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setDisplayOptions(int, int)
959ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
969ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public static final int DISPLAY_HOME_AS_UP = 0x4;
979ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
989ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
999ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Show the activity title and subtitle, if present.
1009ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
1019ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setTitle(CharSequence)
1029ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setTitle(int)
1039ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setSubtitle(CharSequence)
1049ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setSubtitle(int)
1059ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setDisplayOptions(int)
1069ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setDisplayOptions(int, int)
1079ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
1089ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public static final int DISPLAY_SHOW_TITLE = 0x8;
1099ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
1109ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
1119ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Show the custom view if one has been set.
1129ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setCustomView(View)
1139ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setDisplayOptions(int)
1149ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #setDisplayOptions(int, int)
1159ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
1169ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public static final int DISPLAY_SHOW_CUSTOM = 0x10;
1179ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
1189ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
1199ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Set the action bar into custom navigation mode, supplying a view
1209ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * for custom navigation.
1219ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
1229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Custom navigation views appear between the application icon and
1239ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * any action buttons and may use any space available there. Common
1249ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * use cases for custom navigation views might include an auto-suggesting
1259ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * address bar for a browser or other navigation mechanisms that do not
1269ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * translate well to provided navigation modes.
1279ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
1289ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @param view Custom navigation view to place in the ActionBar.
12933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
1309ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract void setCustomView(View view);
13189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell
13233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
133a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Set the action bar into custom navigation mode, supplying a view
134a408291e22def5755559f42cde913706a6d628c0Adam Powell     * for custom navigation.
13533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     *
136ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * <p>Custom navigation views appear between the application icon and
13733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * any action buttons and may use any space available there. Common
138a408291e22def5755559f42cde913706a6d628c0Adam Powell     * use cases for custom navigation views might include an auto-suggesting
139a408291e22def5755559f42cde913706a6d628c0Adam Powell     * address bar for a browser or other navigation mechanisms that do not
140ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * translate well to provided navigation modes.</p>
141ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     *
142ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
143ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * the custom view to be displayed.</p>
14433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     *
14533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @param view Custom navigation view to place in the ActionBar.
1469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @param layoutParams How this custom view should layout in the bar.
147ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     *
148ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @see #setDisplayOptions(int, int)
14933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
1509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract void setCustomView(View view, LayoutParams layoutParams);
1519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
1529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
1533f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set the action bar into custom navigation mode, supplying a view
1543f476b34049d062942eafcf48396f593e00bd324Adam Powell     * for custom navigation.
1553f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
1563f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>Custom navigation views appear between the application icon and
1573f476b34049d062942eafcf48396f593e00bd324Adam Powell     * any action buttons and may use any space available there. Common
1583f476b34049d062942eafcf48396f593e00bd324Adam Powell     * use cases for custom navigation views might include an auto-suggesting
1593f476b34049d062942eafcf48396f593e00bd324Adam Powell     * address bar for a browser or other navigation mechanisms that do not
1603f476b34049d062942eafcf48396f593e00bd324Adam Powell     * translate well to provided navigation modes.</p>
1613f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
1623f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
1633f476b34049d062942eafcf48396f593e00bd324Adam Powell     * the custom view to be displayed.</p>
1643f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
1653f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param resId Resource ID of a layout to inflate into the ActionBar.
1663f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
1673f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
1683f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
1693f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setCustomView(int resId);
1703f476b34049d062942eafcf48396f593e00bd324Adam Powell
1713f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
1721969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * Set the icon to display in the 'home' section of the action bar.
1731969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * The action bar will use an icon specified by its style or the
1741969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * activity icon by default.
1751969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
1761969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * Whether the home section shows an icon or logo is controlled
1771969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * by the display option {@link #DISPLAY_USE_LOGO}.
1781969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
1791969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @param resId Resource ID of a drawable to show as an icon.
1801969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
1811969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @see #setDisplayUseLogoEnabled(boolean)
1821969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @see #setDisplayShowHomeEnabled(boolean)
1831969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     */
1841969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell    public abstract void setIcon(int resId);
1851969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell
1861969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell    /**
1871969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * Set the icon to display in the 'home' section of the action bar.
1881969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * The action bar will use an icon specified by its style or the
1891969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * activity icon by default.
1901969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
1911969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * Whether the home section shows an icon or logo is controlled
1921969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * by the display option {@link #DISPLAY_USE_LOGO}.
1931969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
1941969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @param icon Drawable to show as an icon.
1951969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
1961969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @see #setDisplayUseLogoEnabled(boolean)
1971969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @see #setDisplayShowHomeEnabled(boolean)
1981969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     */
1991969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell    public abstract void setIcon(Drawable icon);
2001969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell
2011969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell    /**
2021969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * Set the logo to display in the 'home' section of the action bar.
2031969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * The action bar will use a logo specified by its style or the
2041969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * activity logo by default.
2051969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
2061969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * Whether the home section shows an icon or logo is controlled
2071969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * by the display option {@link #DISPLAY_USE_LOGO}.
2081969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
2091969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @param resId Resource ID of a drawable to show as a logo.
2101969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
2111969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @see #setDisplayUseLogoEnabled(boolean)
2121969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @see #setDisplayShowHomeEnabled(boolean)
2131969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     */
2141969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell    public abstract void setLogo(int resId);
2151969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell
2161969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell    /**
2171969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * Set the logo to display in the 'home' section of the action bar.
2181969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * The action bar will use a logo specified by its style or the
2191969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * activity logo by default.
2201969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
2211969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * Whether the home section shows an icon or logo is controlled
2221969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * by the display option {@link #DISPLAY_USE_LOGO}.
2231969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
2241969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @param logo Drawable to show as a logo.
2251969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     *
2261969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @see #setDisplayUseLogoEnabled(boolean)
2271969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     * @see #setDisplayShowHomeEnabled(boolean)
2281969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell     */
2291969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell    public abstract void setLogo(Drawable logo);
2301969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell
2311969b8799085322f9ef6e75b78c2c9a5d5944801Adam Powell    /**
2329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Set the adapter and navigation callback for list navigation mode.
2339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
2349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * The supplied adapter will provide views for the expanded list as well as
2359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * the currently selected item. (These may be displayed differently.)
2369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
2378515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * The supplied OnNavigationListener will alert the application when the user
2389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * changes the current list selection.
2399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
2409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @param adapter An adapter that will provide views both to display
2419ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *                the current navigation selection and populate views
2429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *                within the dropdown navigation menu.
2438515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * @param callback An OnNavigationListener that will receive events when the user
2449ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *                 selects a navigation item.
2459ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
2469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract void setListNavigationCallbacks(SpinnerAdapter adapter,
2478515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell            OnNavigationListener callback);
2489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
2499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
2509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Set the selected navigation item in list or tabbed navigation modes.
251178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     *
252178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     * @param position Position of the item to select.
253178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     */
254178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell    public abstract void setSelectedNavigationItem(int position);
255178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell
256178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell    /**
2579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Get the position of the selected navigation item in list or tabbed navigation modes.
258178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     *
259178097727fab0f41810b1ffd4baf84ff8ed32c42Adam Powell     * @return Position of the selected item.
2609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
2619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract int getSelectedNavigationIndex();
2629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
2639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
2649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Get the number of navigation items present in the current navigation mode.
2659ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
2669ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @return Number of navigation items.
2679ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
2689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract int getNavigationItemCount();
2699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
2709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
271ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * Set the action bar's title. This will only be displayed if
272ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * {@link #DISPLAY_SHOW_TITLE} is set.
2730e94b5151d817e600a888448a662208b29b5ef46Adam Powell     *
2740e94b5151d817e600a888448a662208b29b5ef46Adam Powell     * @param title Title to set
275a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
276a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @see #setTitle(int)
277ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @see #setDisplayOptions(int, int)
2780e94b5151d817e600a888448a662208b29b5ef46Adam Powell     */
2790e94b5151d817e600a888448a662208b29b5ef46Adam Powell    public abstract void setTitle(CharSequence title);
2800e94b5151d817e600a888448a662208b29b5ef46Adam Powell
2810e94b5151d817e600a888448a662208b29b5ef46Adam Powell    /**
282ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * Set the action bar's title. This will only be displayed if
283ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * {@link #DISPLAY_SHOW_TITLE} is set.
284a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
285a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @param resId Resource ID of title string to set
286a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
287a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @see #setTitle(CharSequence)
288ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @see #setDisplayOptions(int, int)
289a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     */
290a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell    public abstract void setTitle(int resId);
291a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell
292a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell    /**
293ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * Set the action bar's subtitle. This will only be displayed if
294ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the
295ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * subtitle entirely.
2960e94b5151d817e600a888448a662208b29b5ef46Adam Powell     *
2970e94b5151d817e600a888448a662208b29b5ef46Adam Powell     * @param subtitle Subtitle to set
298a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
299a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @see #setSubtitle(int)
300ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @see #setDisplayOptions(int, int)
3010e94b5151d817e600a888448a662208b29b5ef46Adam Powell     */
3020e94b5151d817e600a888448a662208b29b5ef46Adam Powell    public abstract void setSubtitle(CharSequence subtitle);
3030e94b5151d817e600a888448a662208b29b5ef46Adam Powell
3040e94b5151d817e600a888448a662208b29b5ef46Adam Powell    /**
305ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * Set the action bar's subtitle. This will only be displayed if
306ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * {@link #DISPLAY_SHOW_TITLE} is set.
307a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
308a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @param resId Resource ID of subtitle string to set
309a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     *
310a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     * @see #setSubtitle(CharSequence)
311ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @see #setDisplayOptions(int, int)
312a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell     */
313a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell    public abstract void setSubtitle(int resId);
314a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell
315a66c7b04567a584d73bc4dba2711f5d815e4932dAdam Powell    /**
316a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * Set display options. This changes all display option bits at once. To change
317a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * a limited subset of display options, see {@link #setDisplayOptions(int, int)}.
31833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     *
31933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @param options A combination of the bits defined by the DISPLAY_ constants
32033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     *                defined in ActionBar.
32133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
32233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract void setDisplayOptions(int options);
32333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell
32433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
325a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * Set selected display options. Only the options specified by mask will be changed.
326a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * To change all display option bits at once, see {@link #setDisplayOptions(int)}.
327a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     *
3289ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the
3299ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * {@link #DISPLAY_SHOW_HOME} option.
3305ad7af6fc764f71765b134b8cd51787a7e78753aBen Komalo     * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)
3319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}.
332a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     *
333a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * @param options A combination of the bits defined by the DISPLAY_ constants
334a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     *                defined in ActionBar.
335a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     * @param mask A bit mask declaring which display options should be changed.
336a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell     */
337a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell    public abstract void setDisplayOptions(int options, int mask);
3383f476b34049d062942eafcf48396f593e00bd324Adam Powell
3393f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3403f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether to display the activity logo rather than the activity icon.
3413f476b34049d062942eafcf48396f593e00bd324Adam Powell     * A logo is often a wider, more detailed image.
3423f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3433f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3443f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3453f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param useLogo true to use the activity logo, false to use the activity icon.
3463f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3473f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
3483f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
3493f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
3503f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayUseLogoEnabled(boolean useLogo);
3513f476b34049d062942eafcf48396f593e00bd324Adam Powell
3523f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3533f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether to include the application home affordance in the action bar.
3543f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Home is presented as either an activity icon or logo.
3553f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3563f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3573f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3583f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param showHome true to show home, false otherwise.
3593f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3603f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
3613f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
3623f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
3633f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayShowHomeEnabled(boolean showHome);
3643f476b34049d062942eafcf48396f593e00bd324Adam Powell
3653f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3663f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether home should be displayed as an "up" affordance.
3673f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set this to true if selecting "home" returns up by a single level in your UI
3683f476b34049d062942eafcf48396f593e00bd324Adam Powell     * rather than back to the top level or front page.
3693f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3703f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3713f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3723f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param showHomeAsUp true to show the user that selecting home will return one
3733f476b34049d062942eafcf48396f593e00bd324Adam Powell     *                     level up rather than to the top level of the app.
3743f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3753f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
3763f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
3773f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
3783f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
3793f476b34049d062942eafcf48396f593e00bd324Adam Powell
3803f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3813f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether an activity title/subtitle should be displayed.
3823f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3833f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3843f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3853f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param showTitle true to display a title/subtitle if present.
3863f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3873f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
3883f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
3893f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
3903f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayShowTitleEnabled(boolean showTitle);
3913f476b34049d062942eafcf48396f593e00bd324Adam Powell
3923f476b34049d062942eafcf48396f593e00bd324Adam Powell    /**
3933f476b34049d062942eafcf48396f593e00bd324Adam Powell     * Set whether a custom view should be displayed, if set.
3943f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3953f476b34049d062942eafcf48396f593e00bd324Adam Powell     * <p>To set several display options at once, see the setDisplayOptions methods.
3963f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3973f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @param showCustom true if the currently set custom view should be displayed, false otherwise.
3983f476b34049d062942eafcf48396f593e00bd324Adam Powell     *
3993f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int)
4003f476b34049d062942eafcf48396f593e00bd324Adam Powell     * @see #setDisplayOptions(int, int)
4013f476b34049d062942eafcf48396f593e00bd324Adam Powell     */
4023f476b34049d062942eafcf48396f593e00bd324Adam Powell    public abstract void setDisplayShowCustomEnabled(boolean showCustom);
4033f476b34049d062942eafcf48396f593e00bd324Adam Powell
404a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell    /**
40533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * Set the ActionBar's background.
40633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     *
40733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @param d Background drawable
40833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
40933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract void setBackgroundDrawable(Drawable d);
410ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell
411ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell    /**
412ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     * @return The current custom view.
413ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell     */
414ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell    public abstract View getCustomView();
415ef704447689cb991049d31e67be41e66e8a44b6dAdam Powell
41633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
417a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns the current ActionBar title in standard mode.
418a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns null if {@link #getNavigationMode()} would not return
419a408291e22def5755559f42cde913706a6d628c0Adam Powell     * {@link #NAVIGATION_MODE_STANDARD}.
420a408291e22def5755559f42cde913706a6d628c0Adam Powell     *
421a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @return The current ActionBar title or null.
42233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
42333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract CharSequence getTitle();
42433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell
42533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
426a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns the current ActionBar subtitle in standard mode.
427a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns null if {@link #getNavigationMode()} would not return
428a408291e22def5755559f42cde913706a6d628c0Adam Powell     * {@link #NAVIGATION_MODE_STANDARD}.
429a408291e22def5755559f42cde913706a6d628c0Adam Powell     *
430a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @return The current ActionBar subtitle or null.
43133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
43233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract CharSequence getSubtitle();
43333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell
43433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
435a408291e22def5755559f42cde913706a6d628c0Adam Powell     * Returns the current navigation mode. The result will be one of:
436a408291e22def5755559f42cde913706a6d628c0Adam Powell     * <ul>
437a408291e22def5755559f42cde913706a6d628c0Adam Powell     * <li>{@link #NAVIGATION_MODE_STANDARD}</li>
4389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * <li>{@link #NAVIGATION_MODE_LIST}</li>
439a408291e22def5755559f42cde913706a6d628c0Adam Powell     * <li>{@link #NAVIGATION_MODE_TABS}</li>
440a408291e22def5755559f42cde913706a6d628c0Adam Powell     * </ul>
441a408291e22def5755559f42cde913706a6d628c0Adam Powell     *
44233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @return The current navigation mode.
443a408291e22def5755559f42cde913706a6d628c0Adam Powell     *
444661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #setStandardNavigationMode()
445a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @see #setStandardNavigationMode(CharSequence)
446a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @see #setStandardNavigationMode(CharSequence, CharSequence)
447a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @see #setDropdownNavigationMode(SpinnerAdapter)
448661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #setTabNavigationMode()
449a408291e22def5755559f42cde913706a6d628c0Adam Powell     * @see #setCustomNavigationMode(View)
45033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
45133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract int getNavigationMode();
4529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
4539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
4549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Set the current navigation mode.
4559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
4569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @param mode The new mode to set.
4579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #NAVIGATION_MODE_STANDARD
4589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #NAVIGATION_MODE_LIST
4599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @see #NAVIGATION_MODE_TABS
4609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
4619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract void setNavigationMode(int mode);
4629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
46333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    /**
46433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     * @return The current set of display options.
46533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell     */
46633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    public abstract int getDisplayOptions();
467661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
468661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
469661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * Create and return a new {@link Tab}.
470661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * This tab will not be included in the action bar until it is added.
471661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
4722f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn     * <p>Very often tabs will be used to switch between {@link Fragment}
4732f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn     * objects.  Here is a typical implementation of such tabs:</p>
4742f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn     *
4752f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn     * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java
4762f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn     *      complete}
4772f04883ff880966d63d1aa4a1c7b05e497cfcc58Dianne Hackborn     *
478661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @return A new Tab
479661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
480661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #addTab(Tab)
481661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @see #insertTab(Tab, int)
482661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
483661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract Tab newTab();
484661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
485661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
486661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
48781b8944131946e451b31665652de8cc71d81ea07Adam Powell     * If this is the first tab to be added it will become the selected tab.
488661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
489661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param tab Tab to add
490661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
491661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract void addTab(Tab tab);
492661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
493661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
49481b8944131946e451b31665652de8cc71d81ea07Adam Powell     * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
49581b8944131946e451b31665652de8cc71d81ea07Adam Powell     *
49681b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param tab Tab to add
49781b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param setSelected True if the added tab should become the selected tab.
49881b8944131946e451b31665652de8cc71d81ea07Adam Powell     */
49981b8944131946e451b31665652de8cc71d81ea07Adam Powell    public abstract void addTab(Tab tab, boolean setSelected);
50081b8944131946e451b31665652de8cc71d81ea07Adam Powell
50181b8944131946e451b31665652de8cc71d81ea07Adam Powell    /**
5022b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * Add a tab for use in tabbed navigation mode. The tab will be inserted at
50381b8944131946e451b31665652de8cc71d81ea07Adam Powell     * <code>position</code>. If this is the first tab to be added it will become
50481b8944131946e451b31665652de8cc71d81ea07Adam Powell     * the selected tab.
505661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
506661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param tab The tab to add
507661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param position The new position of the tab
508661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
5092b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    public abstract void addTab(Tab tab, int position);
510661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
511661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
51281b8944131946e451b31665652de8cc71d81ea07Adam Powell     * Add a tab for use in tabbed navigation mode. The tab will be insterted at
51381b8944131946e451b31665652de8cc71d81ea07Adam Powell     * <code>position</code>.
51481b8944131946e451b31665652de8cc71d81ea07Adam Powell     *
51581b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param tab The tab to add
51681b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param position The new position of the tab
51781b8944131946e451b31665652de8cc71d81ea07Adam Powell     * @param setSelected True if the added tab should become the selected tab.
51881b8944131946e451b31665652de8cc71d81ea07Adam Powell     */
51981b8944131946e451b31665652de8cc71d81ea07Adam Powell    public abstract void addTab(Tab tab, int position, boolean setSelected);
52081b8944131946e451b31665652de8cc71d81ea07Adam Powell
52181b8944131946e451b31665652de8cc71d81ea07Adam Powell    /**
5229ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Remove a tab from the action bar. If the removed tab was selected it will be deselected
5239ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * and another tab will be selected if present.
524661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
525661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param tab The tab to remove
526661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
527661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract void removeTab(Tab tab);
528661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
529661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
5309ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Remove a tab from the action bar. If the removed tab was selected it will be deselected
5319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * and another tab will be selected if present.
532661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
533661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param position Position of the tab to remove
534661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
535661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract void removeTabAt(int position);
536661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
537661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
5389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Remove all tabs from the action bar and deselect the current tab.
5399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
5409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract void removeAllTabs();
5419ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
5429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
543661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * Select the specified tab. If it is not a child of this action bar it will be added.
544661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
5459ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p>
5469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
547661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * @param tab Tab to select
548661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
549661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public abstract void selectTab(Tab tab);
550661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
551661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
5522b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * Returns the currently selected tab if in tabbed navigation mode and there is at least
5532b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * one tab present.
5542b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     *
5552b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * @return The currently selected tab or null
5562b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     */
5572b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    public abstract Tab getSelectedTab();
5582b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
5592b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    /**
5609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Returns the tab at the specified index.
5619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
5629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @param index Index value in the range 0-get
5639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @return
5649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
5659ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public abstract Tab getTabAt(int index);
5669ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
5679ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
5680c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * Returns the number of tabs currently registered with the action bar.
5690c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * @return Tab count
5700c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     */
5710c24a5514c1ff143a223720a090b19a86a75945fAdam Powell    public abstract int getTabCount();
5720c24a5514c1ff143a223720a090b19a86a75945fAdam Powell
5730c24a5514c1ff143a223720a090b19a86a75945fAdam Powell    /**
5746b336f835d637853800b94689375a03f337139a4Adam Powell     * Retrieve the current height of the ActionBar.
5756b336f835d637853800b94689375a03f337139a4Adam Powell     *
5766b336f835d637853800b94689375a03f337139a4Adam Powell     * @return The ActionBar's height
5776b336f835d637853800b94689375a03f337139a4Adam Powell     */
5786b336f835d637853800b94689375a03f337139a4Adam Powell    public abstract int getHeight();
5796b336f835d637853800b94689375a03f337139a4Adam Powell
5806b336f835d637853800b94689375a03f337139a4Adam Powell    /**
5816b336f835d637853800b94689375a03f337139a4Adam Powell     * Show the ActionBar if it is not currently showing.
5826b336f835d637853800b94689375a03f337139a4Adam Powell     * If the window hosting the ActionBar does not have the feature
5836b336f835d637853800b94689375a03f337139a4Adam Powell     * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
5846b336f835d637853800b94689375a03f337139a4Adam Powell     * content to fit the new space available.
5856b336f835d637853800b94689375a03f337139a4Adam Powell     */
5866b336f835d637853800b94689375a03f337139a4Adam Powell    public abstract void show();
5876b336f835d637853800b94689375a03f337139a4Adam Powell
5886b336f835d637853800b94689375a03f337139a4Adam Powell    /**
5896b336f835d637853800b94689375a03f337139a4Adam Powell     * Hide the ActionBar if it is not currently showing.
5906b336f835d637853800b94689375a03f337139a4Adam Powell     * If the window hosting the ActionBar does not have the feature
5916b336f835d637853800b94689375a03f337139a4Adam Powell     * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
5926b336f835d637853800b94689375a03f337139a4Adam Powell     * content to fit the new space available.
5936b336f835d637853800b94689375a03f337139a4Adam Powell     */
5946b336f835d637853800b94689375a03f337139a4Adam Powell    public abstract void hide();
5956b336f835d637853800b94689375a03f337139a4Adam Powell
5966b336f835d637853800b94689375a03f337139a4Adam Powell    /**
5976b336f835d637853800b94689375a03f337139a4Adam Powell     * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise.
5986b336f835d637853800b94689375a03f337139a4Adam Powell     */
5996b336f835d637853800b94689375a03f337139a4Adam Powell    public abstract boolean isShowing();
6006b336f835d637853800b94689375a03f337139a4Adam Powell
6016b336f835d637853800b94689375a03f337139a4Adam Powell    /**
6028515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * Add a listener that will respond to menu visibility change events.
6038515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     *
6048515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * @param listener The new listener to add
6058515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     */
6068515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener);
6078515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell
6088515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    /**
6098515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * Remove a menu visibility listener. This listener will no longer receive menu
6108515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * visibility change events.
6118515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     *
6128515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * @param listener A listener to remove that was previously added
6138515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     */
6148515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener);
6158515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell
6168515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    /**
617c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * Enable or disable the "home" button in the corner of the action bar. (Note that this
618c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * is the application home/up affordance on the action bar, not the systemwide home
619c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * button.)
620c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     *
621c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * <p>This defaults to true for packages targeting &lt; API 14. For packages targeting
622c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * API 14 or greater, the application should call this method to enable interaction
623c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * with the home/up affordance.
624c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     *
625c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * <p>Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable
626c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * the home button.
627c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     *
628c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     * @param enabled true to enable the home button, false to disable the home button.
629c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell     */
63088ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell    public void setHomeButtonEnabled(boolean enabled) { }
63188ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell
63288ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell    /**
63388ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell     * Returns a {@link Context} with an appropriate theme for creating views that
63488ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell     * will appear in the action bar. If you are inflating or instantiating custom views
63588ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell     * that will appear in an action bar, you should use the Context returned by this method.
63688ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell     * (This includes adapters used for list navigation mode.)
63788ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell     * This will ensure that views contrast properly against the action bar.
63888ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell     *
63988ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell     * @return A themed Context for creating views
64088ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell     */
64188ab69780f58e4b32d497266b2ad646a4d74827bAdam Powell    public Context getThemedContext() { return null; }
642c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell
643c29f4e52c3377924df26910cce3ff26278d1f484Adam Powell    /**
6448515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * Listener interface for ActionBar navigation events.
64589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell     */
6468515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    public interface OnNavigationListener {
64789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell        /**
64889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * This method is called whenever a navigation item in your action bar
64989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * is selected.
65089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         *
65189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * @param itemPosition Position of the item clicked.
65289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * @param itemId ID of the item clicked.
65389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         * @return True if the event was handled, false otherwise.
65489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell         */
65589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell        public boolean onNavigationItemSelected(int itemPosition, long itemId);
65633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell    }
657661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
658661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    /**
6598515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     * Listener for receiving events when action bar menus are shown or hidden.
6608515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell     */
6618515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    public interface OnMenuVisibilityListener {
6628515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell        /**
6638515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         * Called when an action bar menu is shown or hidden. Applications may want to use
6648515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         * this to tune auto-hiding behavior for the action bar or pause/resume video playback,
6658515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         * gameplay, or other activity within the main content area.
6668515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         *
6678515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         * @param isVisible True if an action bar menu is now visible, false if no action bar
6688515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         *                  menus are visible.
6698515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell         */
6708515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell        public void onMenuVisibilityChanged(boolean isVisible);
6718515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    }
6728515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell
6738515ee846bd76aee86ec5ddfcc4dd1e626dd999cAdam Powell    /**
674661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * A tab in the action bar.
675661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     *
676661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     * <p>Tabs manage the hiding and showing of {@link Fragment}s.
677661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell     */
678661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    public static abstract class Tab {
679661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
680661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * An invalid position for a tab.
681661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
682661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @see #getPosition()
683661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
684661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public static final int INVALID_POSITION = -1;
685661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
686661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
687661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Return the current position of this tab in the action bar.
688661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
689661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in
690661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *         the action bar.
691661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
692661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public abstract int getPosition();
693661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
694661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
695661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Return the icon associated with this tab.
696661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
697661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @return The tab's icon
698661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
699661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public abstract Drawable getIcon();
700661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
701661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
702661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Return the text of this tab.
703661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
704661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @return The tab's text
705661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
706661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public abstract CharSequence getText();
707661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
708661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
709661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Set the icon displayed on this tab.
710661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
711661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @param icon The drawable to use as an icon
7129ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
713661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
7149ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setIcon(Drawable icon);
715661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
716661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
71732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * Set the icon displayed on this tab.
71832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         *
71932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @param resId Resource ID referring to the drawable to use as an icon
72032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @return The current instance for call chaining
72132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         */
72232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        public abstract Tab setIcon(int resId);
72332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell
72432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        /**
725661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Set the text displayed on this tab. Text may be truncated if there is not
726661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * room to display the entire string.
727661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
728661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * @param text The text to display
7299ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
730661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
7319ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setText(CharSequence text);
732661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
733661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
73432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * Set the text displayed on this tab. Text may be truncated if there is not
73532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * room to display the entire string.
73632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         *
73732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @param resId A resource ID referring to the text that should be displayed
73832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @return The current instance for call chaining
73932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         */
74032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        public abstract Tab setText(int resId);
74132555f347974711aac1f0c9acc0f06e8676d9362Adam Powell
74232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        /**
7432b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Set a custom view to be used for this tab. This overrides values set by
7442b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
745661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
7462b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param view Custom view to be used as a tab.
7479ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
748661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
7499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setCustomView(View view);
750661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
751661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
75232555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * Set a custom view to be used for this tab. This overrides values set by
75332555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
75432555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         *
75532555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @param layoutResId A layout resource to inflate and use as a custom tab view
75632555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         * @return The current instance for call chaining
75732555f347974711aac1f0c9acc0f06e8676d9362Adam Powell         */
75832555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        public abstract Tab setCustomView(int layoutResId);
75932555f347974711aac1f0c9acc0f06e8676d9362Adam Powell
76032555f347974711aac1f0c9acc0f06e8676d9362Adam Powell        /**
7612b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Retrieve a previously set custom view for this tab.
762661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         *
7632b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @return The custom view set by {@link #setCustomView(View)}.
764661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
7652b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        public abstract View getCustomView();
7662b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
7672b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
7682b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Give this Tab an arbitrary object to hold for later use.
7692b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *
7702b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param obj Object to store
7719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
7722b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
7739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setTag(Object obj);
7742b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
7752b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
7762b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @return This Tab's tag object.
7772b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
7782b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        public abstract Object getTag();
7792b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
7802b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
7812b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Set the {@link TabListener} that will handle switching to and from this tab.
7822b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * All tabs must have a TabListener set before being added to the ActionBar.
7832b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *
7842b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param listener Listener to handle tab selection events
7859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @return The current instance for call chaining
7862b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
7879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public abstract Tab setTabListener(TabListener listener);
788661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell
789661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        /**
790661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         * Select this tab. Only valid if the tab has been added to the action bar.
791661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell         */
792661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell        public abstract void select();
793661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell    }
7942b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
7952b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    /**
7962b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * Callback interface invoked when a tab is focused, unfocused, added, or removed.
7972b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     */
7982b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    public interface TabListener {
7992b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
8002b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Called when a tab enters the selected state.
8012b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *
8022b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param tab The tab that was selected
8032b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
8042b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *        during a tab switch. The previous tab's unselect and this tab's select will be
8050c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        executed in a single transaction. This FragmentTransaction does not support
8060c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        being added to the back stack.
8072b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
8082b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        public void onTabSelected(Tab tab, FragmentTransaction ft);
8092b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
8102b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        /**
8112b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * Called when a tab exits the selected state.
8122b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *
8132b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param tab The tab that was unselected
8142b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
8152b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         *        during a tab switch. This tab's unselect and the newly selected tab's select
8160c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        will be executed in a single transaction. This FragmentTransaction does not
8170c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        support being added to the back stack.
8182b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell         */
8192b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell        public void onTabUnselected(Tab tab, FragmentTransaction ft);
8207f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell
8217f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell        /**
8227f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         * Called when a tab that is already selected is chosen again by the user.
8237f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         * Some applications may use this action to return to the top level of a category.
8247f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         *
8257f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         * @param tab The tab that was reselected.
8267f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
8270c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        once this method returns. This FragmentTransaction does not support
8280c24a5514c1ff143a223720a090b19a86a75945fAdam Powell         *        being added to the back stack.
8297f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell         */
8307f9b90542e05b350d14bd63c16446c8ce2baf407Adam Powell        public void onTabReselected(Tab tab, FragmentTransaction ft);
8312b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    }
8329ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8339ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    /**
8349ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * Per-child layout information associated with action bar custom views.
8359ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     *
8369ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity
8379ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell     */
8389ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    public static class LayoutParams extends MarginLayoutParams {
8399ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        /**
8409ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * Gravity for the view associated with these LayoutParams.
8419ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         *
8429ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         * @see android.view.Gravity
8439ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell         */
8449ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        @ViewDebug.ExportedProperty(category = "layout", mapping = {
8459ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from =  -1,                       to = "NONE"),
8469ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.NO_GRAVITY,        to = "NONE"),
8479ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.TOP,               to = "TOP"),
8489ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.BOTTOM,            to = "BOTTOM"),
8499ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.LEFT,              to = "LEFT"),
8509ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.RIGHT,             to = "RIGHT"),
8519ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL,   to = "CENTER_VERTICAL"),
8529ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL,     to = "FILL_VERTICAL"),
8539ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),
8549ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL,   to = "FILL_HORIZONTAL"),
8559ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.CENTER,            to = "CENTER"),
8569ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            @ViewDebug.IntToString(from = Gravity.FILL,              to = "FILL")
8579ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        })
8589ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public int gravity = -1;
8599ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8609ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(Context c, AttributeSet attrs) {
8619ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(c, attrs);
8629ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8639ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            TypedArray a = c.obtainStyledAttributes(attrs,
8649ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell                    com.android.internal.R.styleable.ActionBar_LayoutParams);
8659ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            gravity = a.getInt(
8669ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell                    com.android.internal.R.styleable.ActionBar_LayoutParams_layout_gravity, -1);
8679ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8689ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8699ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(int width, int height) {
8709ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(width, height);
8719ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
8729ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8739ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8749ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(int width, int height, int gravity) {
8759ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(width, height);
8769ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            this.gravity = gravity;
8779ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8789ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8799ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(int gravity) {
8809ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            this(WRAP_CONTENT, MATCH_PARENT, gravity);
8819ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8829ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8839ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(LayoutParams source) {
8849ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(source);
8859ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8869ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            this.gravity = source.gravity;
8879ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8889ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell
8899ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        public LayoutParams(ViewGroup.LayoutParams source) {
8909ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell            super(source);
8919ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell        }
8929ab978713ce86fdaefed2407f4f3c998ab0e3178Adam Powell    }
89333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell}
894